Skip to the article
Top Crypto

Crypto markets, protocols, policy

How do you approve the vault relayer for API orders?

To approve the vault relayer before submitting an API order, authorize GPv2VaultRelayer on the sell token, then verify allowance before posting.

The Top Crypto Editors 2 min read

How do you approve the vault relayer for API orders?

To set an ERC-20 allowance for the GPv2VaultRelayer before submitting a CoW Protocol API order, call approve(vaultRelayer, amount) on the sell token from the order owner’s address. GPv2Settlement pulls the sell tokens through the relayer, so an allowance granted to GPv2Settlement is never used.

  1. Start with the wallet that holds the sell token. You need the order owner’s key or signer, the sell token’s address, and the chain’s native token to pay gas.

  2. Read vaultRelayer() from GPv2Settlement on the target chain. Fetch the address per network instead of reusing a hardcoded value. On Ethereum, GPv2VaultRelayer is 0xC92E8bdf79f0507f65a392b0ab4667716BFE0110.

  3. Call approve(vaultRelayer, amount) on the sell token, signed by the order owner. Set the allowance high enough to cover the sell amount plus the fee. The spender is GPv2VaultRelayer; approving GPv2Settlement leaves the relayer without the allowance it needs.

  4. Wait for the approval transaction to confirm. Tokens such as USDT may require you to first set an existing nonzero allowance to zero, confirm that transaction, then approve the new amount. An earlier approval through cowswap from this same address already covers API orders if it grants the needed allowance to the same relayer. The linked cowswap smart order adds background on how signed orders fit into the execution flow.

  5. Read allowance(owner, vaultRelayer) from the sell token contract. Confirm it is at least the sell amount plus fee, and that the owner still has enough token balance. The orderbook API checks allowance and balance when you submit; if either is short, it rejects the order. Once the checks pass, post the signed order to the CoW Protocol API. An order UID in the API response confirms the order was accepted.