This example uses the unified deposit API which automatically detects the optimal authorization method (permit vs approval).
Prerequisites
- Node.js 18+
- viem 2+
- Amplify API key from Paxos Labs
Installation
Complete Example
What This Code Does
- Initializes the SDK - Required before any SDK calls
- Connects to wallet - Uses injected provider (MetaMask, etc.)
- Checks authorization - Determines permit, approval, or already approved
- Signs permit if supported - Off-chain signature for gas efficiency
- Sends transactions - Approval and/or deposit
- Waits for confirmation - Uses
waitForTransactionReceipt
Key Features
- No React required - Pure TypeScript/JavaScript
- Full transaction lifecycle - From authorization to confirmation
- Console logging - Clear progress indicators
- Error handling - Proper async/await with catch
Running the Script
Expected Output
Customization
Custom Slippage
Partner Code
Force Approval Flow
Troubleshooting
For more details, see Deposits.