Overview
This example covers:- Getting a cross-chain swap quote
- Generating transaction bytecode
- Executing the swap transaction
- Monitoring transaction status across chains
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 Cross-Chain Quote
Cross-chain swaps use bridge providers like TeleSwap or Mayan and may take several minutes to complete.
3. Generate Bytecode
4. Execute Origin Transactions (atomic batch)
5. Monitor Status
Use the quote ID for quote status. The bytecode response also returns anid; use it with GET /actions/{id} when you need the execution record.
Webhook Alternative
Instead of polling, you can configure webhooks to receive status updates:Error Handling
Running the Example
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