Peer Cash SDK
@zkp2p/cash is Peer's offramp-only TypeScript SDK. Use it in a wallet, app, Node service, or agent to cash out Base USDC to a fiat payment platform. Assets on other chains can be routed into Base USDC first.
The cashing-out user is the maker. They create a Base USDC deposit at the live market rate. A buyer signals an intent, pays the user in fiat, and proves the payment with TEE-TLS. The protocol then releases the matching USDC to the buyer.
Peer Cash SDK or ZKP2P SDK?
| Peer Cash SDK | ZKP2P SDK | |
|---|---|---|
| Package | @zkp2p/cash | @zkp2p/sdk |
| Best for | A cash-out product | A custom protocol integration |
| User role | Maker only | Maker, taker, or both |
| Pricing | On-chain oracle rate when a buyer signals, zero spread | Set by your integration |
| Asset path | Base USDC, or another asset routed into Base USDC through Relay or NEAR Intents | Protocol and API primitives you choose |
| Workflow | Built-in order lifecycle with typed recovery | Deposits, intents, fulfillment, quotes, proofs, vaults, rate managers, hooks |
| Signing | viem signer or unsigned Base USDC transaction plans | Direct and prepared protocol transactions |
| React | @zkp2p/cash/react | @zkp2p/sdk/react |
| Agent tooling | JSON-schema tool manifest in @zkp2p/cash/tools | Build your own |
Choose Peer Cash when cash-out is the product. It has no API for custom spreads, buyer-side intents or proofs, disputes, seller-credential uploads, vaults, delegated rate management, or arbitrary contract calls. For those, use the ZKP2P SDK.
How a cash-out works
Optional source asset
│
│ Relay or NEAR Intents route
▼
Base USDC deposit at zero spread
│
│ buyer signals an intent
▼
Buyer pays the maker through a supported fiat app
│
│ TEE-TLS payment proof
▼
Protocol releases USDC to the buyer
The protocol contracts hold the funds; the SDK never holds keys. The maker can withdraw unmatched funds at any time, and withdraw() prunes expired buyer intents first.
Installation
npm install @zkp2p/cash viem
# or
yarn add @zkp2p/cash viem
# or
pnpm add @zkp2p/cash viem
# or
bun add @zkp2p/cash viem
The current stable release is @zkp2p/cash@0.7.3. It needs Node 22 or newer and viem 2.37.3 or newer within 2.x. React 18 or newer is an optional peer dependency, used only by @zkp2p/cash/react.
Cash 0.7.3 pins @zkp2p/sdk@0.14.10. If your app also depends on @zkp2p/sdk, use the same version so one copy resolves.
Quick start
import { createCashClient, usdc } from "@zkp2p/cash";
const cash = createCashClient({ environment: "production" });
const chime = cash
.capabilities()
.platforms.find(({ platform }) => platform === "chime");
if (!chime?.currencies.includes("USD")) {
throw new Error("Chime USD is not available in this environment");
}
const estimate = await cash.estimate({
amount: usdc(100),
currency: "USD",
platform: "chime",
});
console.log(`Approximately ${estimate.receiveAmount} USD`);
const result = await cash.cashout(
{
amount: usdc(100),
receive: {
platform: "chime",
currency: "USD",
payee: { offchainId: "$your-chime-sign" },
},
},
{ signer },
);
await saveCashOrder({
userId,
depositId: result.depositId,
transactionHash: result.txHash,
});
signer is a viem WalletClient on Base with an account. Persist depositId right away: it is the resume key for order(), watch(), topUp(), and withdraw().
In 0.7.3, cashout() attaches the retired Peer Pay merchant group to Venmo and PayPal deposits. Create those cash-outs with prepare() instead. See Protected payout rails.
One order can offer several ways to get paid: a leg can list several currencies, and receive accepts an array of legs on different platforms. Every option fills at its live zero-spread oracle rate. See Offer several currencies or platforms.
estimate() reads the current oracle rate and can include a historical fill-time estimate. Each buyer's rate binds when they signal an intent. Show the value as approximate, honor estimate.stale, and don't present the ETA as a guarantee.
The lifecycle
The SDK rebuilds every order state from protocol data.
| State | Meaning | Typical next action |
|---|---|---|
awaiting-buyer | The deposit is live and no buyer has an active intent | Wait, top up, or withdraw |
matched | A buyer has signaled and the matching USDC is locked | Wait for payment and proof, or for the intent to expire |
delivering | Part of the order is fulfilled and more remains active | Keep observing |
delivered | Fiat was proven and the filled USDC was released | Reconcile the verified fill data |
returned | Remaining funds were withdrawn to the maker | None |
Use order.nextActions (wait, withdraw) and order.explain() instead of tracking state yourself. watch(depositId) yields changes until the order reaches a terminal state. orders(owner, { inFlight: true }) lists a wallet's active orders.
Purpose-built entry points
| Entry point | Use it for |
|---|---|
@zkp2p/cash | Discovery, estimates, signed operations, unsigned plans, order reads, codecs, and typed errors |
@zkp2p/cash/react | useEstimate, useCashout, useOrder, and useOrders |
@zkp2p/cash/tools | JSON-schema tool definitions for an agent host, CLI, or policy-controlled signer |
Every transaction the SDK builds carries ERC-8021 attribution, starting with peer-cash. Add your own analytics codes with referrer. To earn Peer's integration share on the flow you bring, pass your Peer referral code as referralCode; see Earn from the flow you bring.
Optional receipt linking
Venmo and X Money users can link the inbox that receives their payment receipts through a page Peer hosts. Linking is a separate step: cashout() and prepare() never invoke or require it. See Optional Venmo receipt linking.
Next step
Continue to the integration guide for signed and unsigned transaction paths, Relay source routing, React hooks, error recovery, and staging verification.