Skip to main content
This example demonstrates a complete deposit flow using Privy for wallet management and the unified deposit API.
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

  1. Checks authorization method - Determines if permit, approval, or already approved
  2. Handles permit flow - Signs typed data off-chain for gas-efficient authorization
  3. Handles approval flow - Sends approval transaction then deposit
  4. Handles pre-approved - Deposits directly if allowance exists
  5. 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.