Overview
CoW Protocol supports multiple signing schemes to accommodate different types of accounts:- EIP-712: Structured data signing for EOAs (recommended)
- EthSign: Legacy
eth_signsignature for EOAs - EIP-1271: Smart contract signature verification
- PreSign: On-chain order approval
SigningScheme Enum
EIP-712 typed data signing scheme. This is the recommended method as it provides clear information to wallets about what is being signed.Reference: EIP-712 Specification
Legacy message signing using the
eth_sign RPC call. Provides less context to users about what they’re signing.Smart contract signatures as defined in EIP-1271. Used for contract-based accounts like multi-sigs and smart wallets.Reference: EIP-1271 Specification
Pre-signed orders approved on-chain. The order signature is validated by checking on-chain storage.
Signature Types
EcdsaSignature
ECDSA signature for EOA signers:Eip1271Signature
Signature for smart contract signers:PreSignSignature
Signature for pre-signed orders:Signature Union Type
Signing Functions
signOrder
Signs an order using ECDSA (EIP-712 or EthSign):The EIP-712 domain for the settlement contract. Prevents replay attacks across chains and deployments.
The order to sign.
The ethers.js signer (wallet) that will sign the order.
The signing scheme:
SigningScheme.EIP712 (recommended) or SigningScheme.ETHSIGN.The order signature with the signing scheme encoded.
Examples
EIP-712 Signing (Recommended)
EIP-712 is the recommended signing method because it shows users a structured representation of the order data in their wallet, making it clear what they’re signing.
EthSign Signing
EIP-1271 Smart Contract Signatures
For smart contract wallets (multi-sigs, etc.):PreSign Orders
For orders approved on-chain:EIP-1271 Helper Functions
encodeEip1271SignatureData
Encodes EIP-1271 signature data for the settlement contract:decodeEip1271SignatureData
Decodes EIP-1271 signature data:Constants
EIP1271_MAGICVALUE
The magic value returned by a successful EIP-1271 signature verification:isValidSignature function defined in EIP-1271 when a signature is valid.
Complete Signing Example
Best Practices
Use EIP-712
Always prefer EIP-712 signing for EOAs as it provides the best user experience and security.
Verify Domain
Always use the correct domain with the right chain ID and settlement contract address.
Handle Errors
Catch and handle signing errors gracefully, as users may reject the signature request.
Test Signatures
Test signature recovery to ensure the signer matches the expected owner address.
Next Steps
Settlement Encoding
Learn how to encode signed orders into settlements
Order Management
Back to order creation and management
