1. Access & Environment
- Request a Paxos-issued Amplify API key for your environment (sandbox, staging, production).
- Store the key as a secret (
.env, HashiCorp Vault, CI secrets manager). - Confirm network access to required RPC endpoints (Alchemy, Infura, or your in-house nodes).
- Decide where transactions are signed (end-user wallet via Privy, custodial flow, or backend signer).
2. Scaffold the App
- Follow the Quickstart to spin up a Vite + React + Privy project.
- Mirror the recommended Directory Structure and create providers for Privy, Amplify, and your data cache.
- Add feature flags or progressive rollout gates if you are staging Earn access.
3. Initialize the SDK
- Call
initAmplifySDK(apiKey)once on boot (client or server). - Wrap the call in a provider that throws if the key is missing or the init step fails.
- Track initialization metrics to catch missing environment variables early.
4. Discover Vaults & Assets
- Use
fetchSupportedAssetsto build product selectors.
- Cache results (React Query, SWR, server-side caches) with sensible revalidation periods.
- Map vault metadata to your UI components (APY, supported assets, min/max).
5. Execute Flows
Our focus is on providing the best UX possible for our users. The Unified Deposit API simplifies this with automatic authorization detection.Unified Deposit API (Recommended)
The unified API automatically determines the optimal authorization method:| Authorization Method | Description |
|---|---|
PERMIT | EIP-2612 off-chain signature (gas efficient, single transaction) |
APPROVAL | Traditional ERC20 approval (two transactions) |
ALREADY_APPROVED | Existing allowance sufficient (no authorization needed) |
Flow Comparison
| Flow | Functions | Transactions | Best For |
|---|---|---|---|
| Unified Deposit | prepareDepositAuthorization, prepareDeposit | 1-2 | All cases (recommended) |
| Permit Deposit | prepareDepositPermitSignature, prepareDepositWithPermitTxData | 1 | EIP-2612 tokens only |
| Approve & Deposit | prepareApproveDepositTokenTxData, prepareDepositTxData | 2 | Legacy integration |
| Withdraw | prepareApproveWithdrawTxData, prepareWithdrawTxData | 2 | All withdrawals |
Notes
- Each helper returns deterministic calldata and throws
APIErrorwith actionable metadata. - Execute transactions with
viem,wagmi, or Privy helpers—never with rawethers.jsstrings. - Record failed transactions alongside the
endpointvalue to accelerate debugging. - Default slippage is 50 basis points (0.5%). Increase for volatile conditions.
6. Error Handling
All SDK functions throwAPIError with actionable information:
| Error Code | Description |
|---|---|
SDK_NOT_INITIALIZED | Call initAmplifySDK() before other functions |
VAULT_NOT_FOUND | No vault matches the yieldType, token, and chainId |
PERMIT_NOT_SUPPORTED | Token doesn’t support EIP-2612, use approval flow |
INSUFFICIENT_ALLOWANCE | Need larger approval or use permit |