@usdctofiat/offramp adds a USDC off-ramp in one function call.
The SDK is the fast path to selling USDC from your own app. One call validates input, approves USDC, registers the seller, creates the deposit on Base, and delegates pricing. It targets Base mainnet and is permissionless for deposit creation.
Install and create a deposit
- 1Install the package: bun add @usdctofiat/offramp (npm and pnpm work too).
- 2Pass a viem WalletClient: the user's wallet, a server wallet, or a bot wallet.
- 3Call offramp(walletClient, { amount, platform, currency, identifier }).
- 4Read 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 when the handle is not yet registered |
| Validation | PLATFORMS and CURRENCIES expose identifier and currency validation |
| No key custody | The SDK signs with your WalletClient and never stores private keys |
Keep exploring
Common questions
Is @usdctofiat/offramp free?
Yes. The SDK is free to install and integrate, and creating deposits needs no API key because your wallet signs. Peerlytics analytics, API credits, and signed webhook management are available separately through Peerlytics.
Does the SDK custody keys or move fiat?
No to both. It signs with the viem WalletClient you provide and never holds private keys. Fiat moves directly between buyer and seller on the chosen payment app; the SDK only handles the onchain USDC and deposit lifecycle.
How do I test an integration?
There is no public sandbox; the SDK targets Base mainnet, so a test deposit is real and discoverable on the open orderbook. Use the 1 USDC minimum and either restrict it as an OTC deposit (pass otcTaker so only your wallet can fill it) or close() it quickly. Confirm onchain and via deposits().