This example uses the unified deposit API which automatically detects the optimal authorization method (permit vs approval).
Prerequisites
- Node.js 18+
- wagmi v2+ configured in your app
- Amplify API key from Paxos Labs
Installation
Complete Example
useDeposit Hook
Deposit Component
What This Code Does
- Uses wagmi hooks -
useAccount,useWriteContract,useSignTypedData - Checks authorization method - Determines optimal path automatically
- Signs permits with wagmi - Uses
signTypedDataAsyncfor EIP-712 - Writes contracts with wagmi - Uses
writeContractAsyncfor transactions - Tracks loading state - Disables form during processing
Key Features
- Native wagmi integration - Works with your existing wagmi setup
- Automatic chain handling - Uses connected chain from
useAccount - Type-safe hooks - Full TypeScript support
- Composable architecture - Separate hook from UI component
Benefits of This Pattern
Troubleshooting
For more details, see Deposits.