Skip to main content

Overview

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 the SigningScheme enum:
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
  • Supported by all modern wallets

ETHSIGN (Legacy)

ETHSIGN uses the eth_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

Limitations of ETHSIGN:
  • Signs a raw hash without context
  • Wallets show cryptic hex strings
  • Less secure user experience
  • Being phased out by modern wallets
Use EIP-712 whenever possible. ETHSIGN is primarily for backward compatibility.

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 calls isValidSignature() 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 the setPreSignature() function on the CoW Protocol settlement contract to mark an order as approved:

Use Cases

Smart Contract Integration

Protocols can approve orders programmatically without ECDSA signatures

On-Chain Governance

DAOs can vote to approve orders through governance

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:
The SDK automatically handles the details:

Order Signing Workflow

1

Create Order Parameters

Define your order with all required fields (tokens, amounts, validity, etc.)
2

Normalize Order

The SDK normalizes the order (converts timestamps, validates fields)
3

Sign Order

Call OrderSigningUtils.signOrder() which attempts EIP-712, then ETHSIGN if needed
4

Submit Order

Send the order with signature and signing scheme to the OrderBook API

Signature Validation

The settlement contract validates signatures based on the scheme:

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

Verify Wallet Type

Detect smart contract wallets and use EIP-1271 signing flow

Cache Signatures

For repeated orders, consider pre-signing or caching where appropriate

Troubleshooting

  • Ensure chainId matches the network you’re signing for
  • Check that the order parameters match exactly (no modifications after signing)
  • Verify the signer address matches the order owner
  • The SDK will automatically fall back to ETHSIGN
  • Some older wallets don’t support EIP-712
  • Consider updating wallet or using WalletConnect
  • Verify the contract implements EIP-1271 correctly
  • Ensure the order hash is approved in the contract’s logic
  • Check gas limits for the isValidSignature call
  • Confirm the setPreSignature transaction was mined
  • Verify you’re using the correct order UID
  • Check that the transaction was sent from the order owner address

Next Steps

App Data

Learn about order metadata

Order Types

Understand order parameters

Order Signing Utils

API reference for signing