Skip to main content

App Data

Overview

App Data is a flexible metadata system enabling developers to attach additional information to CoW Protocol orders. It supports developer attribution, analytics tracking, custom hooks, and more.

What is App Data?

App Data is a 32-byte hash (bytes32) stored in every order that points to a JSON document containing metadata. The document can include slippage tolerance, order classification, UTM tracking, partner fees, CoW Hooks, and custom application data.

App Data Structure

Creating App Data

Basic Usage

Using in Orders

Default UTM Parameters

The SDK automatically includes UTM parameters:

Overriding UTM Parameters

Custom UTM parameters completely replace the defaults when provided.

Partner Fees

Partner fees are deducted from order surplus and don’t affect minimum user output.

CoW Hooks

CoW Hooks execute custom contract calls before and/or after order execution, enabling token approvals, reward claiming, staking, and arbitrary DeFi operations.

Hook Structure

Pre-Hooks Example

Post-Hooks Example

Hook Limitations:
  • Hooks execute in the same transaction as the order
  • Failed hooks cause the entire transaction to revert
  • Set appropriate gas limits to avoid out-of-gas errors
  • Only use trusted contracts as hook targets

Advanced Usage

Merging App Data

Custom Metadata Fields

IPFS Integration

The CoW Protocol API automatically uploads app data to IPFS when you submit orders.

Retrieving App Data

Common Patterns

Market Order:
Limit Order:
With Partner Fee:
With Custom UTM:

Best Practices

  • Use Descriptive App Codes: Choose clear, unique identifiers for analytics
  • Set Appropriate Slippage: Market orders 0.5-1%, limit orders 0%, volatile tokens higher
  • Test Hooks Thoroughly: Always test on testnets before production
  • Cache App Data Hashes: Reuse identical metadata hashes to reduce IPFS uploads

Troubleshooting

App data hash mismatch: Ensure the exact fullAppData JSON string with deterministic formatting is used. The SDK handles this automatically. Hook execution failed: Verify target contract address, callData encoding matches function signature, gasLimit is sufficient, and test hook separately. Custom UTM not appearing: When providing metadata.utm, it replaces all defaults. Set all desired UTM fields explicitly.

Next Steps

Last modified on March 4, 2026