Skip to main content
This example demonstrates a complete deposit flow using pure viem without React, suitable for Node.js scripts or vanilla TypeScript applications.
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

  1. Initializes the SDK - Required before any SDK calls
  2. Connects to wallet - Uses injected provider (MetaMask, etc.)
  3. Checks authorization - Determines permit, approval, or already approved
  4. Signs permit if supported - Off-chain signature for gas efficiency
  5. Sends transactions - Approval and/or deposit
  6. 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.