What is CoW Protocol SDK?
The CoW Protocol SDK is a comprehensive TypeScript toolkit for building trading applications on CoW Protocol, an intent-based decentralized exchange that protects users from MEV (Maximal Extractable Value) and offers the best available prices through batch auctions. Using CoW Protocol, you can perform swaps, limit orders, TWAP orders, and many other operations. The SDK provides tools at different abstraction levels, allowing you to conveniently implement basic scenarios while maintaining the flexibility to control all possible cases.In most cases, you will only need to use the TradingSdk - the main tool for swap and limit orders with built-in quote fetching, order signing, and posting.
Key Features
Intent-Based Trading
Express trading intent without specifying execution path. CoW Protocol finds the best route and price.
MEV Protection
Built-in protection from front-running, sandwich attacks, and other MEV strategies through batch auctions.
Gasless Trading
Network costs are internalized in the order price - no upfront gas fees for traders.
Best Prices
Orders compete in batch auctions across multiple liquidity sources including AMMs and private market makers.
Supported Networks
The SDK supports all CoW Protocol enabled networks:Ethereum
Chain ID: 1 -
SupportedChainId.MAINNETGnosis Chain
Chain ID: 100 -
SupportedChainId.GNOSIS_CHAINArbitrum One
Chain ID: 42161 -
SupportedChainId.ARBITRUM_ONEBase
Chain ID: 8453 -
SupportedChainId.BASEPolygon
Chain ID: 137 -
SupportedChainId.POLYGONAvalanche
Chain ID: 43114 -
SupportedChainId.AVALANCHELens
Chain ID: 232 -
SupportedChainId.LENSBNB Chain
Chain ID: 56 -
SupportedChainId.BNBLinea
Chain ID: 59144 -
SupportedChainId.LINEAPlasma
Chain ID: 9745 -
SupportedChainId.PLASMAInk
Chain ID: 57073 -
SupportedChainId.INKSepolia (Testnet)
Chain ID: 11155111 -
SupportedChainId.SEPOLIASDK Components
Core
TradingSdk
Main tool for swap and limit orders with built-in quote fetching, order signing, and posting
OrderSigningUtils
Utilities for signing orders and cancellations using cryptographic algorithms
OrderBookApi
Retrieve orders and trades from the CoW Protocol order book, as well as add and cancel them
MetadataApi
API for accessing order metadata and additional information
Advanced
BridgingSdk
Cross-chain token transfers and bridging functionality
ConditionalOrder
SDK for Programmatic Orders such as TWAP
CowShedSdk
Account abstraction that leverages EOA with smart contract capabilities
Basic Trading Flow
The typical workflow for executing a trade on CoW Protocol:
The SDK handles all of these steps automatically, calculating proper amounts, managing metadata, and handling network-specific parameters.
Test Coverage
| Statements | Branches | Functions | Lines |
|---|---|---|---|
| 94.77% | 76.78% | 97.43% | 97.67% |
Next Steps
Installation
Install the SDK and choose your adapter
Quickstart
Create your first swap in under 5 minutes
Examples
Explore working code examples
API Reference
Dive into the complete API documentation