Recommended Directory Structure
A consistent file layout keeps vault logic, wallet plumbing, and UI concerns easy to reason about:Separation of Concerns
- Providers layer – initialize Privy, React Query, and the Amplify SDK once. Re-export hooks for the rest of the app.
- Hooks layer – wrap SDK helpers (
prepareDeposit,prepareWithdrawal) with domain-specific logic and query invalidation. - Components layer – pure UI components that receive prepared data plus callbacks for execution.
- Lib layer – interaction helpers for viem, Privy, or analytics that should not depend on React state.
SDK Initialization
All Amplify SDK functions require initialization before use. CallinitAmplifySDK() once at application startup.
Basic Initialization
With Custom RPCs
For the best user experience and reliability, we recommend using your own RPCs:With Configuration Options
React Integration Hook
Create a hook to initialize the SDK once and expose ready state:Usage in App
Environment Variables
Create.env.local (ignored by Vite by default):
Global Providers
Set up React Query and your wallet provider:Server-Side Usage
If you execute transactions from a backend service, mirror the same separation:server/app.ts– Express/Fastify entry pointserver/clients/amplify.ts–initAmplifySDKand helper wrappersserver/services/deposits.ts– orchestrates approvals, permits, or withdrawals
Next Steps
- Follow the Deposits guide to implement your first deposit flow
- See initAmplifySDK for full API reference
- Check Logging for debug configuration