Overview
This example covers:- Getting an executable cross-chain quote in one call (
GET /v2/swap/quotewith wallet addresses) - Executing the origin-chain legs as one atomic EIP-7702 batch
- Monitoring status across chains (
quoteIdvs the Actionid)
Prerequisites
- Node.js 18+
- Pods API key
- Wallet with tokens on the origin chain
- Basic understanding of async/await
Choose Your Library
- ethers.js
- viem
Using ethers.js v6 for blockchain interactions - the most popular Ethereum library.
Installation
- ethers.js
- viem
Environment Variables
Create a.env file:
Step-by-Step Walkthrough
1. Initialize API Client
2. Get an Executable Cross-Chain Quote (one call)
PassoriginAddress, destinationAddress, and refundAddress so the response already includes
executable transactionData for the origin chain. New integrations should not call the legacy
POST /v2/swap/bytecode.
quote.quoteId and the top-level id are different identifiers. Use quote.quoteId with
GET /v2/swap/status/{quoteId} for quote settlement, and the top-level id with
GET /actions/{id} for the on-chain Action execution record. Cross-chain swaps use bridge
providers like TeleSwap or Mayan and may take several minutes to complete.3. Execute Origin Transactions (atomic batch)
4. Monitor Status
Poll quote settlement withquote.quoteId. When you need the on-chain Action execution record
instead, poll GET /actions/${actionId} with the top-level id from the quote response.
Webhook Alternative
Instead of polling, you can configure webhooks to receive status updates:Error Handling
Running the Example
Download both files into the same folder to run this example:
cross-chain-swap.js and the shared EIP-7702 batch
helper eip7702-batch.js that it imports.Expected Output
Next Steps
Same-Chain Swap
Execute same-chain token swaps
Strategy Deposit
Deposit into yield strategies
Swap Guide
Learn more about swaps
API Reference
View complete API documentation