Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-docs-quality-audit-1774257282.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Signing Schemes
Order signature methods supported by CoW ProtocolOverview
CoW Protocol supports multiple signing schemes to accommodate different wallet types and use cases. Understanding these schemes is crucial for implementing order signing in your application.Available Signing Schemes
The protocol supports four signing schemes, defined in theSigningScheme enum:
EIP-712 (Recommended)
EIP-712 is the preferred signing scheme. It provides structured, human-readable data to wallets, making signatures safer and more transparent for users.How It Works
EIP-712 creates typed, structured data that wallets can display to users before signing:Type Definition
The EIP-712 type structure for CoW Protocol orders:Benefits of EIP-712:
- Users can see exactly what they’re signing
- Better UX with clear wallet prompts
- Improved security against phishing attacks
- Supported by all modern wallets
ETHSIGN (Legacy)
ETHSIGN uses theeth_sign RPC method, which is a legacy signing approach. The SDK automatically falls back to this method if EIP-712 signing fails.
When It’s Used
EIP-1271 (Smart Contract Wallets)
EIP-1271 enables smart contract wallets (like Safe/Gnosis Safe, Argent) to validate signatures on-chain.How It Works
Instead of an ECDSA signature, the order includes the contract address. The settlement contract callsisValidSignature() on the wallet contract to verify the order.
Integration Example
For Safe wallets or other smart contract wallets:The smart contract wallet must have the order hash approved (via internal logic or governance) before the settlement contract can execute the order.
PRESIGN (On-Chain Approval)
PRESIGN allows orders to be approved on-chain before execution, without requiring a cryptographic signature.How It Works
Users call thesetPreSignature() function on the CoW Protocol settlement contract to mark an order as approved:
Use Cases
Smart Contract Integration
Protocols can approve orders programmatically
On-Chain Governance
DAOs can vote to approve orders
Batch Operations
Approve multiple orders in a single transaction
Emergency Actions
Pre-authorize orders for specific scenarios
Integration Example
ECDSA Signing Schemes
EIP-712 and ETHSIGN are both ECDSA-based schemes:Order Signing Workflow
Sign Order
Call
OrderSigningUtils.signOrder() which attempts EIP-712 first, then falls back to ETHSIGNSignature Validation
The settlement contract validates signatures based on the scheme:- EIP-712
- ETHSIGN
- EIP-1271
- PRESIGN
Best Practices
Prefer EIP-712
Always use EIP-712 when possible for the best security and UX.
Handle Fallback
The SDK automatically tries ETHSIGN if EIP-712 fails. Don’t disable this fallback.
Verify Wallet Type
Detect smart contract wallets and use the appropriate signing flow (EIP-1271 or PRESIGN).
Cache Signatures
Consider pre-signing orders for repeated trading patterns.
Troubleshooting
Signature verification failed
Signature verification failed
- Verify the chain ID matches the network you’re signing for
- Ensure the order parameters haven’t changed after signing
- Check that the signer address matches the order owner
Wallet rejects EIP-712 signature
Wallet rejects EIP-712 signature
- The SDK will automatically fall back to ETHSIGN
- Some older wallets don’t support EIP-712
- Check wallet compatibility
Smart contract wallet issues
Smart contract wallet issues
- Verify the contract implements
isValidSignature() - Ensure the order is approved in the contract’s internal state
- Check that the contract address is correct
PRESIGN not working
PRESIGN not working
- Verify the
setPreSignaturetransaction was confirmed - Check the order UID matches exactly
- Ensure the pre-sign was done from the correct address
Next Steps
App Data
Add metadata to your orders
Order Types
Learn about different order types
Order Signing Utils
API reference for signing utilities