Overview
App Data is a flexible metadata system that allows you to attach additional information to CoW Protocol orders. It’s a critical part of order creation, enabling features like 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. This document follows a standardized schema and can include:
- Slippage tolerance settings
- Order classification (market, limit, etc.)
- UTM tracking parameters for analytics
- Partner fee information
- CoW Hooks (pre/post execution callbacks)
- Custom application-specific data
App Data Structure
The app data document has this structure:Creating App Data
The SDK provides utilities to create and manage app data:Basic Usage
Using in Orders
Default UTM Parameters
The SDK automatically includes UTM parameters for developer attribution:Overriding UTM Parameters
When you provide custom UTM parameters, they completely replace the defaults. The SDK only adds default UTM when none are provided.
Partner Fees
You can specify partner fees to receive a portion of the surplus:Partner fees are deducted from the order’s surplus (the difference between executed price and limit price). They don’t affect the minimum output amount users receive.
CoW Hooks
CoW Hooks allow you to execute custom contract calls before and/or after an order executes. This enables advanced use cases like:- Approve tokens just-in-time
- Claim rewards before trading
- Stake tokens after purchase
- Execute arbitrary DeFi operations
Hook Structure
Pre-Hooks Example
Executed before the order:Post-Hooks Example
Executed after the order:Advanced Usage
Merging App Data
You can merge additional metadata into existing app data:Custom Metadata Fields
You can add custom fields to the metadata:IPFS Integration
App data documents are stored on IPFS for decentralized access:Retrieving App Data
Fetch app data from an existing order:Common Patterns
Best Practices
Use Descriptive App Codes
Choose clear, unique
appCode values to identify your application in analytics.Set Appropriate Slippage
Market orders: 0.5-1%. Limit orders: 0%. Volatile tokens: higher values.
Test Hooks Thoroughly
Always test hooks on testnets before production. Failed hooks revert the entire order.
Cache App Data Hashes
For identical metadata, reuse the same app data hash to reduce IPFS uploads.
Troubleshooting
App data hash mismatch
App data hash mismatch
Ensure you’re using the exact
fullAppData JSON string (deterministic formatting) when computing the hash. The SDK handles this automatically.Hook execution failed
Hook execution failed
- Check that the target contract address is correct
- Verify the callData encoding matches the function signature
- Ensure the gasLimit is sufficient
- Test the hook call separately before including in an order
Custom UTM not appearing
Custom UTM not appearing
If you provide a
metadata.utm object, it completely replaces defaults. Make sure you’re setting all desired UTM fields.Next Steps
Order Types
Learn about different order types
Trading SDK
Start building with the SDK
Hooks Guide
Advanced hooks implementation