Skip to main content

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.MAINNET

Gnosis Chain

Chain ID: 100 - SupportedChainId.GNOSIS_CHAIN

Arbitrum One

Chain ID: 42161 - SupportedChainId.ARBITRUM_ONE

Base

Chain ID: 8453 - SupportedChainId.BASE

Polygon

Chain ID: 137 - SupportedChainId.POLYGON

Avalanche

Chain ID: 43114 - SupportedChainId.AVALANCHE

Lens

Chain ID: 232 - SupportedChainId.LENS

BNB Chain

Chain ID: 56 - SupportedChainId.BNB

Linea

Chain ID: 59144 - SupportedChainId.LINEA

Plasma

Chain ID: 9745 - SupportedChainId.PLASMA

Ink

Chain ID: 57073 - SupportedChainId.INK

Sepolia (Testnet)

Chain ID: 11155111 - SupportedChainId.SEPOLIA

SDK 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:
1

Get a quote

Request a price quote from the CoW Protocol API for your trade parameters
2

Sign the order

Sign the order using EIP-712 signature with your wallet
3

Post to order book

Submit the signed order to the CoW Protocol order book for execution
The SDK handles all of these steps automatically, calculating proper amounts, managing metadata, and handling network-specific parameters.

Test Coverage

StatementsBranchesFunctionsLines
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

Resources

Build docs developers (and LLMs) love