Skip to main content

Build trading applications on CoW Protocol

A complete TypeScript SDK for intent-based trading with support for swaps, limit orders, TWAP, cross-chain bridging, and programmatic orders across 11+ networks.

Intent-Based Trading
MEV-protected execution
Multi-Chain Support
11+ networks supported
Advanced Orders
TWAP, DCA, conditional

Quick start

Get up and running with CoW Protocol SDK in minutes

1

Install the SDK

Install the CoW Protocol SDK and your preferred adapter package:
npm install @cowprotocol/cow-sdk @cowprotocol/sdk-viem-adapter viem
2

Configure the adapter

Set up your blockchain adapter with provider and signer:
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
import { createPublicClient, http, privateKeyToAccount } from 'viem'
import { mainnet } from 'viem/chains'

const adapter = new ViemAdapter({
  provider: createPublicClient({
    chain: mainnet,
    transport: http('YOUR_RPC_URL')
  }),
  signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
})
3

Initialize the Trading SDK

Create your Trading SDK instance:
import { TradingSdk, SupportedChainId } from '@cowprotocol/cow-sdk'

const sdk = new TradingSdk({
  chainId: SupportedChainId.MAINNET,
  appCode: 'YOUR_APP_CODE'
}, {}, adapter)
4

Create your first swap

Get a quote and execute a swap:
import { OrderKind } from '@cowprotocol/cow-sdk'

const { quoteResults, postSwapOrderFromQuote } = await sdk.getQuote({
  kind: OrderKind.SELL,
  sellToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
  sellTokenDecimals: 18,
  buyToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  buyTokenDecimals: 6,
  amount: '1000000000000000000' // 1 WETH
})

// Review quote and post order
const orderId = await postSwapOrderFromQuote()
console.log('Order created:', orderId)

Explore by feature

Everything you need to build sophisticated trading applications

Swap & Limit Orders

Create market swaps and limit orders with automatic quote fetching and order signing

Cross-Chain Bridging

Transfer tokens across chains with integrated bridge providers and multi-quote comparison

Programmatic Orders

Implement TWAP, DCA, and conditional orders that execute automatically

Smart Wallets

Support smart contract wallets with pre-sign and account abstraction

Order Management

Retrieve order status, cancel orders on-chain or off-chain, and track trades

Token Approvals

Manage ERC-20 token approvals for the CoW Protocol Vault Relayer

API reference

Complete documentation for all SDK components

TradingSdk

Main trading interface

OrderBookApi

Order book operations

BridgingSdk

Cross-chain bridging

OrderSigningUtils

Order signing utilities

ConditionalOrder

Programmatic orders

Adapters

Blockchain adapters

Ready to start building?

Follow our quickstart guide to create your first trade in minutes, or explore the full API reference for advanced use cases.

Build docs developers (and LLMs) love