Overview
This example covers:- Getting a swap quote
- Generating transaction bytecode
- Executing the swap transaction
- Handling approvals
Prerequisites
- Node.js 18+
- Pods API key
- Ethereum wallet with tokens to swap
- 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 Swap Quote
3. Generate Bytecode
4. Execute Transactions (atomic batch)
output=userOperation on POST /v2/swap/bytecode instead.
Error Handling
Running the Example
Expected Output
Next Steps
Cross-Chain Swap
Execute cross-chain token swaps
Strategy Deposit
Deposit into yield strategies
Swap Guide
Learn more about swaps
API Reference
View complete API documentation