Overview
This guide covers interacting with CoW Protocol smart contracts, signing orders using EIP-712 typed data, and understanding the various signing schemes supported by the protocol.
Core Concepts
CoW Protocol uses EIP-712 typed structured data for order signing, which provides:
- Human-readable signature requests in wallets
- Domain separation to prevent replay attacks
- Type safety for order parameters
Setting Up the Domain
The EIP-712 domain identifies the protocol and chain:
Creating Orders
Orders are created using the Order dataclass:
Signing Schemes
CoW Protocol supports multiple signing schemes:
EIP-712 (Recommended)
The preferred method using typed structured data:
ETH_SIGN
Alternative signing method using eth_sign:
EIP-1271 (Smart Contract Signatures)
For smart contract wallets implementing EIP-1271:
PRESIGN (Gnosis Safe)
For Gnosis Safe multisig wallets:
Order Hashing
Compute order hashes for verification:
Canceling Orders
Single Order Cancellation
Batch Cancellation
Order Types
Sell Orders
Buy Orders
Partially Fillable Orders
Token Balance Sources
Complete Contract Interaction Example
Contract Addresses
Security Considerations
Private Key Safety: Never commit private keys to version control. Use environment variables or secure key management services.
- Order Validation: Always validate order parameters before signing. Check token addresses, amounts, and validity periods.
- Domain Separation: The EIP-712 domain prevents signatures from being used on different chains or protocols.
Next Steps