Install and create a deposit
- 01Install the package: bun add @usdctofiat/offramp (npm and pnpm work too).
- 02Pass a viem WalletClient: the user's wallet, a server wallet, or a bot wallet.
- 03Call offramp(walletClient, { amount, platform, currency, identifier }).
- 04Read the returned depositId and txHash, or scaffold a project with npx create-offramp-app@latest.
The SDK surface
| Export | What it does |
|---|---|
| offramp(walletClient, params) | One-call sell-USDC flow returning { depositId, txHash, resumed, otcLink? } |
| deposits(address) | List deposits for an address without indexing protocol state |
| close(walletClient, depositId) | Withdraw unfilled USDC from an existing deposit |
| enableOtc / disableOtc / getOtcLink | Manage private one-buyer restriction on a deposit |
| useOfframp() / usePeerExtensionRegistration() | React hooks from @usdctofiat/offramp/react |
| PLATFORMS, CURRENCIES | Typed const maps with identifiers, validation, and currency lists |
Resumable by design
Creating a deposit spans several onchain steps. If a previous call left a deposit mid-flight, calling offramp() again picks up where it left off rather than creating a duplicate. The result's resumed flag is true when an existing undelegated deposit was adopted instead of created.
That makes the SDK safe to retry from a server or bot: an idempotency-friendly entry point that reconciles against onchain state instead of assuming a clean slate.
Error handling
| Concern | How the SDK signals it |
|---|---|
| Typed errors | OfframpError carries a code from OFFRAMP_ERROR_CODES |
| PayPal or Wise setup | EXTENSION_REGISTRATION_REQUIRED signals technical setup only; enforce provider policy separately |
| Validation | PLATFORMS and CURRENCIES expose identifier and currency validation |
| No key custody | The SDK signs with your WalletClient and never stores private keys |