Skip to main content
This example demonstrates a complete deposit flow using wagmi React hooks 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+
  • wagmi v2+ configured in your app
  • Amplify API key from Paxos Labs

Installation

Complete Example

useDeposit Hook

Deposit Component

What This Code Does

  1. Uses wagmi hooks - useAccount, useWriteContract, useSignTypedData
  2. Checks authorization method - Determines optimal path automatically
  3. Signs permits with wagmi - Uses signTypedDataAsync for EIP-712
  4. Writes contracts with wagmi - Uses writeContractAsync for transactions
  5. 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.