Overview
This example covers:- Checking existing strategy positions
- Generating withdrawal transaction bytecode
- Withdrawing to the same chain
- Withdrawing cross-chain with
toChainIdandtoTokenAddress - Executing the returned transactions
- Tracking cross-chain completion by ID
Prerequisites
- Node.js 18+
- Pods API key
- Wallet with an existing position in the selected strategy
- RPC URL for the strategy chain
- Basic understanding of async/await
Installation
Environment Variables
Create a.env file:
Step-by-Step Walkthrough
1. Initialize API Client
2. Check Current Positions
3. Generate Same-Chain Withdrawal Bytecode
4. Generate Cross-Chain Withdrawal Bytecode
To withdraw from the strategy chain and bridge the proceeds to another chain, passtoChainId or chainIdOut plus toTokenAddress.
The
amount is the amount to withdraw from the source strategy. For cross-chain withdrawals, Pods returns origin-chain transaction bytecode and a quote describing the destination-chain output.5. Execute Transactions (atomic batch)
6. Track Cross-Chain Withdrawal Status
Cross-chain withdrawals complete asynchronously after the origin-chain transactions are confirmed. Use the returnedid to track completion.
Same-chain withdrawals do not require polling because the withdrawal completes inline with the user’s signed transaction. You can still call
GET /actions/:id with the returned id for record-keeping.Running the Example
Expected Output
Next Steps
Strategy Deposit
Deposit into yield strategies
Yield Withdrawal Guide
Review all withdrawal parameters and response shapes
Cross-Chain Swap
Execute cross-chain token swaps
API Reference
View complete API documentation