Native Token Swaps
Learn how to sell blockchain native tokens (like ETH on Ethereum) using CoW Protocol’s EthFlow contract.Overview
Native tokens (ETH, MATIC, etc.) require special handling because they’re not ERC-20 tokens. CoW Protocol uses the EthFlow contract to enable native token trading through on-chain transactions.Currently, only selling native tokens is supported. To buy native tokens, trade for wrapped versions (e.g., WETH) first.
How It Works
When you sell native tokens:- An on-chain transaction is sent to the EthFlow contract
- Your native tokens are locked in the contract
- The order is created in the CoW Protocol order book
- When filled, you receive your buy tokens
- If unfilled, you can cancel and reclaim your native tokens
1
Create order with native token address
Use the special address
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native tokens2
SDK sends on-chain transaction
Your native tokens are sent to the EthFlow contract
3
Order is created
The order appears in the order book and can be filled by solvers
Automatic Detection
ThepostSwapOrder method automatically detects native token orders and uses the EthFlow contract:
Using postSellNativeCurrencyOrder
For more control over native token orders, use the dedicatedpostSellNativeCurrencyOrder method:
Method Signature
Parameters
params- Trade parameters with native token as sell tokenadvancedSettings- Optional advanced settings
Returns
orderId- Unique order identifiertxHash- Transaction hash of the EthFlow transactionsigningScheme- AlwaysSigningScheme.EIP1271for EthFlowsignature- Empty string (signature is the transaction itself)orderToSign- The order parameters
Example
Complete Example with Quote
Get a quote first, then create the order:Order Kinds for Native Tokens
- SELL Orders (Supported)
- BUY Orders (Limited)
Sell native tokens for ERC-20 tokens:✅ Supported: You can sell exactly 1 ETH and receive USDC
For most use cases, use
OrderKind.SELL when trading native tokens for better UX and predictability.Gas Costs
Native token orders are more expensive than regular orders because they require on-chain transactions:Implementation Details
Under the hood, the SDK:- Detects native token by checking if
sellTokenequals the EthFlow marker address - Gets a quote with special EthFlow parameters:
signingScheme: SigningScheme.EIP1271onchainOrder: trueverificationGasLimit: 0(subsidized)
- Creates a transaction to the EthFlow contract
- Uploads app-data to the order book
- Returns the order ID and transaction hash
From the Source Code
Cancelling Native Token Orders
Native token orders can be cancelled on-chain to recover your locked funds:When you cancel an EthFlow order on-chain, your native tokens are automatically refunded.
Advanced: Custom EthFlow Parameters
For advanced use cases, you can customize EthFlow behavior:Common Chains and Native Tokens
Best Practices
- Check balance: Ensure you have enough native tokens plus gas
- Wait for confirmation: Always wait for the EthFlow transaction to confirm
- Monitor gas prices: Native token orders are expensive, wait for low gas
- Use SELL orders: More predictable than BUY orders for native tokens
- Consider WETH: For small amounts, wrapping to WETH might be cheaper
- Handle errors: EthFlow transactions can fail, implement proper error handling
Common Issues and Solutions
Transaction Reverts
Problem: EthFlow transaction reverts. Solution:- Ensure you have enough ETH for both the order amount AND gas
- Check that the order parameters are valid
- Verify the buy token address is correct
Order Not Found After Transaction
Problem: Order UID is returned butgetOrder fails.
Solution: Wait a few seconds for the order to be indexed by the order book before querying.
High Gas Costs
Problem: Native token orders are too expensive. Solution:- Wait for lower gas prices
- For small amounts, consider wrapping to WETH first
- Batch multiple operations if possible
Alternatives: Using Wrapped Native Tokens
For smaller orders, wrapping native tokens first might be more cost-effective:Next Steps
- Learn about Creating Swap Orders for regular ERC-20 trading
- See Order Management to track native token orders
- Explore Token Approvals (not needed for native tokens!)