Types
SigningScheme
Enum representing the signature scheme used to sign an order.EIP-712 typed data signing (preferred). Provides more information to wallets about the data being signed.
Message signed using
eth_sign RPC call.Smart contract signatures as defined in EIP-1271. For contract-based wallets.
Pre-signed order. The order is signed on-chain before submission.
Signature
Union type representing any valid order signature.EcdsaSignature
ECDSA signature for EIP-712 or ETHSIGN schemes.The ECDSA signing scheme used.
The ECDSA signature data (r, s, v components).
Eip1271Signature
EIP-1271 smart contract signature.Must be
SigningScheme.EIP1271.The EIP-1271 signature data containing verifier and signature bytes.
Eip1271SignatureData
Data for EIP-1271 signature verification.The address of the smart contract that will verify the signature.
Arbitrary signature data passed to the verifying contract’s
isValidSignature method.PreSignSignature
Signature data for a pre-signed order.Must be
SigningScheme.PRESIGN.The address of the order signer.
Functions
signOrder
Signs a CoW Protocol order using an externally owned account (EOA).The EIP-712 domain separator. Ensures orders can’t be replayed across different deployments or chains.
The order to sign.
The Ethers.js signer (wallet) that will sign the order.
The signing scheme to use:
SigningScheme.EIP712 (recommended) or SigningScheme.ETHSIGN.The ECDSA signature with the signing scheme encoded.
Example
encodeEip1271SignatureData
Encodes EIP-1271 signature data for use with CoW Protocol contracts.The EIP-1271 signature data to encode.
Hex-encoded signature data with verifier address and signature bytes packed together.
decodeEip1271SignatureData
Decodes a CoW Protocol EIP-1271 signature into its components.The encoded EIP-1271 signature data.
The decoded signature containing the verifier address and signature bytes.
Constants
EIP1271_MAGICVALUE
The magic value returned by a successfulisValidSignature call.
This is
bytes4(keccak256("isValidSignature(bytes32,bytes)")) as defined in the EIP-1271 standard.Usage Notes
EIP-712 is the recommended signing scheme as it provides the best user experience. Wallets can display structured information about what the user is signing.
EIP-1271 is required for smart contract wallets like Gnosis Safe, Argent, or any contract-based wallet that doesn’t have a private key.
Pre-signed orders require an on-chain transaction to authorize the order before it can be settled. This is useful for integration with other smart contracts.
