Skip to main content

OrderSigningUtils

EIP-712 order signing and cancellation utilities for CoW Protocol

Overview

The OrderSigningUtils class provides static methods for signing CoW Protocol orders and cancellations using EIP-712 standards. It supports multiple signing schemes including standard EOA wallets and smart contract wallets.

Installation

Usage

All methods are static and can be called directly on the class.

Methods

signOrder

Signs an order using EIP-712 typed data signing.

Example

Ensure the chainId is correct for your network. An incorrect chainId will result in an invalid signature.

signOrderCancellation

Signs a cancellation for a single order.

Example


signOrderCancellations

Signs a cancellation for multiple orders at once.
More gas-efficient than signing cancellations individually when cancelling multiple orders.

Example


getDomain

Retrieves the EIP-712 typed domain data for a given chain.

Example


getDomainSeparator

Returns the domain separator hash for a given chain.

Example


generateOrderId

Creates a deterministic order ID from order data and owner address.

Example


getEIP712Types

Returns the EIP-712 type definitions for CoW Protocol orders.

Example


getEip1271Signature

Encodes an order and ECDSA signature for EIP-1271 smart contract verification.
Useful for smart contract wallets that implement EIP-1271 signature verification.

Example


encodeUnsignedOrder

Encodes an unsigned order for hashing.

Example

Signing Schemes

EIP-712 (Default)

Standard EIP-712 typed data signing. Provides the best user experience with human-readable signing prompts.

EthSign (EIP-191)

Legacy signing method. Automatically used as fallback if EIP-712 is not supported by the wallet.

Pre-sign

For smart contracts that cannot sign directly. Orders are approved on-chain via setPreSignature().

EIP-1271

For smart contract wallets implementing the EIP-1271 signature verification standard.

Integration Examples

With OrderBookApi

With TradingSdk

Cancelling Orders

Error Handling

Best Practices

  1. Always verify chain ID - Ensure the chainId matches the network you’re operating on. Incorrect chain IDs produce invalid signatures.
  2. Set global adapter - Call setGlobalAdapter() before using OrderSigningUtils to ensure the correct provider is available.
  3. Use typed data (EIP-712) - Prefer EIP-712 signing for the best security and user experience. The SDK handles fallback automatically.
  4. Batch cancellations - Use signOrderCancellations() instead of multiple signOrderCancellation() calls for efficiency.
  5. Handle rejections - Always handle the case where users reject signature requests in their wallet.

See Also

Last modified on March 11, 2026