This instruction type enables direct contract interaction by specifying exact function calls. Provide ABI signatures and arguments to call any EVM contract as part of your supertransaction.
Important: When withdrawing native ETH/tokens (not ERC20), you cannot use the standard ERC20 transfer() function. Use the ETH Forwarder contract instead.
Copy
Ask AI
import { parseUnits, zeroAddress } from 'viem';const quoteRequest = { mode: 'eoa', ownerAddress: account.address, fundingTokens: [{ tokenAddress: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC on Base chainId: 8453, amount: parseUnits('100', 6).toString() }], feeToken: { address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', chainId: 8453 }, composeFlows: [ // Step 1: Swap USDC → Native ETH { type: '/instructions/intent-simple', data: { srcChainId: 8453, dstChainId: 8453, srcToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC dstToken: zeroAddress, // Native ETH (0x0000...0000) amount: parseUnits('100', 6).toString(), slippage: 0.01 } }, // Step 2: Withdraw native ETH to EOA using ETH Forwarder { type: '/instructions/build', data: { functionSignature: 'function forward(address recipient)', args: [ account.address // Recipient (your EOA) ], to: '0x000000Afe527A978Ecb761008Af475cfF04132a1', // ETH Forwarder contract chainId: 8453, value: parseUnits('0.035', 18).toString(), // Amount in wei to forward (~$100 worth) gasLimit: '300000' } } ]};// Then quote → sign → execute
Key Points:
Native tokens are represented using zeroAddress (0x0000000000000000000000000000000000000000)
ETH Forwarder contract: 0x000000Afe527A978Ecb761008Af475cfF04132a1
Use the value field to specify the amount of native tokens to forward
Works for ETH, MATIC, BNB, and all other native tokens
Same forwarder address across all supported chains
// ✅ CorrectfunctionSignature: 'function transfer(address to, uint256 value)'// ❌ Wrong (missing 'function' keyword)functionSignature: 'transfer(address to, uint256 value)'// ❌ Wrong (incorrect parameter names - doesn't matter but be consistent)functionSignature: 'function transfer(address recipient, uint256 amt)'
Use ETH Forwarder for Native Tokens
When withdrawing or transferring native tokens (ETH, MATIC, BNB, etc.), always use the ETH Forwarder contract:
Copy
Ask AI
import { zeroAddress } from 'viem';// ❌ Bad - Cannot use ERC20 transfer for native tokens{ type: '/instructions/build', data: { functionSignature: 'function transfer(address to, uint256 value)', args: [ownerAddress, parseUnits('0.1', 18).toString()], to: zeroAddress, // Native ETH - transfer() won't work chainId: 8453 }}// ✅ Good - Use ETH forwarder for native tokens{ type: '/instructions/build', data: { functionSignature: 'function forward(address recipient)', args: [ownerAddress], to: '0x000000Afe527A978Ecb761008Af475cfF04132a1', // ETH forwarder chainId: 8453, value: parseUnits('0.1', 18).toString(), // Amount to forward gasLimit: '300000' }}