Overview
Use this cookbook when you want to integrate directly with the deployed contracts instead of relying on transaction-building endpoints. This gives you full control over:- token approvals,
- router call parameters,
- wallet UX,
- and transaction submission.
viem, which is also the library used in the current frontend stack.
Prerequisites
- the target router address,
- the source-chain USDC address,
- the instrument ID,
- and a connected wallet client.
Shared Setup
Recipe 1: Same-Chain Buy on Base
minDepositedAmount = 0n is usually acceptable because there is no internal token conversion.
Recipe 2: Cross-Chain Buy From Base To Arbitrum
When the instrument lives on another supported chain, the samebuy() entrypoint routes into the bridge path automatically.
Monitor cross-chain completion
The destination-side redeem is completed asynchronously after attestation. Poll the relay status endpoint using the source tx hash.Direct contract callers do not need to register an operation with the backend. The relay starts from the bridge event webhook.
Recipe 3: Sell Directly Through the Router
When To Use Direct Contracts vs The Transaction API
Use direct contract calls when you want:- fully custom wallet UX,
- explicit control over approvals and router params,
- to avoid backend execution helpers for calldata generation.
- automatic source-chain selection,
- quote normalization and slippage handling,
- ready-to-sign transaction bundles,
- less integration logic in your client.
Common Pitfalls
- forgetting that
amountfor USDC uses 6 decimals - not waiting for approval confirmation before sending
buy()orsell() - assuming cross-chain buys finish in the same transaction as the source-chain
buy() - hardcoding outdated addresses instead of checking the deployment docs
- using the wrong chain for the router call when the instrument lives elsewhere
Next Steps
Contract Addresses
Router, bridge, receiver, and token addresses on each supported chain
API Cookbook
API-assisted execution flow with bundle building and relay monitoring