@usdctofiat/offramp
v9.0.0
Published
One-call non-custodial crypto-to-fiat SDK powered by Peer Cash
Maintainers
Readme
@usdctofiat/offramp
Crypto in. Fiat out. One function.
Add non-custodial cash-out to any wallet or app. Users sell Base USDC to Peer buyers and receive fiat on Revolut, Venmo, Wise, Zelle, PayPal and more at the live market rate with zero spread. No API key, custody or quote engine. New to the flow? Read how USDC to fiat works.
Install
npm install @usdctofiat/offrampRequires Node 22+ and viem 2.x. React 18+ is optional.
Cash out
Pass any connected viem WalletClient on Base:
import { cashout } from "@usdctofiat/offramp";
import type { WalletClient } from "viem";
export async function sellUsdc(signer: WalletClient) {
const order = await cashout({
mode: "fast",
signer,
amount: "100",
currency: "EUR",
platform: "revolut",
payee: "alice",
});
// Save this immediately. It resumes the order from any device or process.
console.log(order.depositId);
return order;
}Strings and numbers are human USDC amounts. A bigint is treated as exact
six-decimal base units.
The call creates a production Base cash-out order and returns after its transaction confirms. A buyer then pays the user fiat and proves the payment onchain.
Fast or best
Choose fast for the direct oracle-priced route at the live rate with 0 bps
spread, or best to delegate pricing to the Delegate rate manager:
const fast = await cashout({ ...input, mode: "fast" });
const best = await cashout({ ...input, mode: "best" });fast.depositId is the composite fast-order resume key and works with
createOfframp().watch() and .withdraw(). best.depositId is the numeric
EscrowV2 deposit id and works with the exported deposits() and close()
helpers. Best mode has the Delegate manager's 10 bps fill fee; fast mode keeps
the direct route's 0 bps spread. The flat helper is production-only and requires
an explicit mode. Use createOfframp(options) for custom routing.
Cash-backed fast supports Venmo and PayPal. Cash App creation fails closed in
9.0.0 until immutable upstream package evidence matches its live zero risk window; exact recovery remains available.
Follow the order
import { createOfframp } from "@usdctofiat/offramp";
export async function watchCashout(depositId: string) {
const cash = createOfframp();
for await (const order of cash.watch(depositId)) {
console.log(order.state, order.explain());
if (!order.isInFlight) return order;
}
}createOfframp() exposes the resumable advanced client: estimates,
capabilities, Relay source routing, multiple payout routes, order history,
withdrawals, top-ups and unsigned transaction preparation.
Pass rollout ids with createOfframp({ disabledPlatforms: "wise,venmo" }) or a flat cashout().
Values accept case-insensitive display or separator forms (Cash App, cash-app, cash_app).
Disabled rails leave capabilities(); new creation fails before wallet use, while exact recovery stays available.
Why this package
- One call to fiat. The common Base USDC path is five fields.
- No dead ends. Every order has readable state and typed recovery guidance.
- More when needed. Private OTC, verified-payee onboarding, React and agent tools ship in the same package without complicating the first call.
This distribution adds peer-ref-TOFIAT and galleonlabs attribution to every
transaction. It cannot be replaced accidentally. Read attribution and
funding for the exact behavior.
Go deeper
- Advanced lifecycle, multi-route, Relay, OTC and recovery
- React hooks
- Verified payees and extension onboarding
- Managed v5 deposits and migration
- Attribution and funding
Focused entries keep imports clear:
import { createManagedOfframp } from "@usdctofiat/offramp/managed";
import { createPeerExtensionSdk } from "@usdctofiat/offramp/extension";
import { cashTools } from "@usdctofiat/offramp/tools";USDCtoFiat · USDC to fiat guide · developer portal · Peer Cash · starter templates
