Package Installation
Install the main SDK package using your preferred package manager:Choose Your Adapter
The CoW SDK requires an adapter to interact with the blockchain. Choose the adapter that matches your Web3 library:Viem
Modern, lightweight TypeScript library
Ethers v6
Latest version of ethers.js
Ethers v5
Legacy ethers.js version
- Viem
- Ethers v6
- Ethers v5
Peer Dependencies
The CoW Protocol SDK has the following peer dependencies that may need to be installed depending on your use case:Required
Optional
These dependencies are only required for specific advanced features:ipfs-only-hashandmultiformats- Required for app-data metadata features@openzeppelin/merkle-tree- Required for merkle tree operations in programmatic orders
Verification
Verify your installation by importing the SDK:Version Information
Current SDK version: v7.4.1If you’re migrating from v6, see the Migration Guide for important breaking changes and upgrade instructions.
TypeScript Configuration
The CoW Protocol SDK is written in TypeScript and includes type definitions. Ensure yourtsconfig.json has:
Environment Setup
Node.js Requirements
The SDK requires Node.js version 16 or higher:Environment Variables
For development, create a.env file to store sensitive information:
.env
Framework-Specific Setup
React / Next.js
For React applications, you’ll typically use the SDK with wagmi or Rainbow Kit:Node.js
For Node.js scripts and backend services:Next Steps
Quickstart Guide
Create your first swap in under 5 minutes
Adapters Concepts
Learn more about adapter configuration
Trading SDK API
Explore the complete TradingSdk API
Examples
Browse working code examples
Troubleshooting
Module not found errors
Module not found errors
Ensure all peer dependencies are installed. Run:or install optional dependencies if using advanced features.
Type errors with adapter
Type errors with adapter
Make sure you’re using the correct adapter for your Web3 library version. Check that:
- Viem adapter requires
viemversion 1.x or higher - Ethers v6 adapter requires
ethersversion 6.x - Ethers v5 adapter requires
ethersversion 5.7.x
RPC connection issues
RPC connection issues
Verify your RPC URL is correct and accessible:Consider using services like Alchemy, Infura, or Tenderly for production.
Network mismatch errors
Network mismatch errors
Ensure the chain ID in your adapter setup matches the chain ID in the TradingSdk:
Getting Help
If you encounter issues during installation:- Check the GitHub Issues
- Join the CoW Protocol Discord
- Review the Examples Repository