This example uses the unified deposit API which automatically detects the optimal authorization method (permit vs approval).
Prerequisites
- Node.js 18+
- Privy App ID from Privy Dashboard
- Amplify API key from Paxos Labs
Installation
Complete Example
useDeposit Hook
Deposit Component
What This Code Does
- Checks authorization method - Determines if permit, approval, or already approved
- Handles permit flow - Signs typed data off-chain for gas-efficient authorization
- Handles approval flow - Sends approval transaction then deposit
- Handles pre-approved - Deposits directly if allowance exists
- Reports status - Updates UI with current operation status
Key Features
- Automatic method detection - SDK chooses optimal authorization path
- Type-safe results - TypeScript discriminated unions for each case
- Status updates - Real-time feedback during multi-step flows
- Error handling - Catches and reports errors with context
Troubleshooting
For more details, see Deposits.