Sell USDC with the Peer SDK
createPeer() in @zkp2p/sdk is the Peer SDK's front door. peer.sell() sells Base USDC for fiat that arrives in the seller's own payment app. Use it in a wallet, app, Node service, or agent.
The seller is the maker. peer.sell() creates a Base USDC deposit at the live market rate. A buyer signals an intent, pays the seller in fiat, and proves the payment with TEE-TLS. The protocol then releases the matching USDC to the buyer.
createPeer() ships in @zkp2p/sdk@0.16.0-rc.1 on the npm rc tag. The latest tag still points to 0.15.x, so pin the exact version. Moving from @zkp2p/cash? Read Migrate from @zkp2p/cash.
peer.sell() or the client reference?
Both live in @zkp2p/sdk.
peer.sell() | Zkp2pClient | |
|---|---|---|
| Best for | A cash-out product | A custom protocol integration |
| User role | Seller (maker) only | Maker, taker, or both |
| Pricing | On-chain oracle rate when a buyer signals, zero spread | Set by your integration |
| Asset | Base USDC | 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 |
Choose peer.sell() when selling USDC for fiat is the product. It has no API for custom spreads, disputes, seller-credential uploads, vaults, delegated rate management, or arbitrary contract calls. For those, use the client reference.
The same client buys USDC with peer.buy. This guide covers selling only. In 0.16.0-rc.1, the full live purchase (signal, pay, and PeerAuth proof) has not been proven on a live network; peer.buy ships on a live staging quote and unit tests.
How a sale works
Base USDC in the seller's wallet
│
│ peer.sell(): deposit at zero spread
▼
Buyer signals an intent
│
│ buyer pays the seller 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 seller can withdraw unmatched funds at any time, and withdraw() prunes expired buyer intents first.
Installation
npm install @zkp2p/sdk@0.16.0-rc.1 viem
# or
yarn add @zkp2p/sdk@0.16.0-rc.1 viem
# or
pnpm add @zkp2p/sdk@0.16.0-rc.1 viem
# or
bun add @zkp2p/sdk@0.16.0-rc.1 viem
The package needs Node 22 or newer and viem ^2.37.3, a peer dependency. It ships ESM and CommonJS builds.
Quick start
import { createPeer, isPeerError, usdc } from "@zkp2p/sdk";
const peer = createPeer({ environment: "production" });
const venmo = peer.sell
.capabilities()
.platforms.find(({ platform }) => platform === "venmo");
if (!venmo?.currencies.includes("USD")) {
throw new Error("Venmo USD is not available in this environment");
}
const estimate = await peer.sell.estimate({
amount: usdc(25),
currency: "USD",
platform: "venmo",
});
console.log(`Approximately ${estimate.receiveAmount} USD`);
try {
const sale = await peer.sell(
{
amount: usdc(25),
receive: { platform: "venmo", currency: "USD", payee: "@your-venmo" },
},
{ signer },
);
await saveSale({
userId,
depositId: sale.depositId,
transactionHash: sale.txHash,
});
for await (const order of peer.sell.watch(sale.depositId)) {
console.log(order.state, order.explain());
}
} catch (error) {
if (!isPeerError(error)) throw error;
console.error(error.code, error.remediation);
}
signer is a viem WalletClient on Base with an account. peer.sell() registers the payee, approves and deposits the USDC, and returns once the deposit confirms. Persist depositId right away: it is the resume key for order(), watch(), topUp(), and withdraw().
One sale 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 seller | None |
Use order.nextActions (wait, withdraw) and order.explain() instead of tracking state yourself. peer.sell.watch(depositId) yields changes until the order reaches a terminal state. peer.sell.orders(owner, { inFlight: true }) lists a wallet's active orders.
Attribution
Every transaction peer.sell() builds carries ERC-8021 attribution, starting with peer-cash, so Peer's indexer classifies SDK sales like earlier cash-outs. 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. To show your label and logo on your deposits in Peer's order books, pass brand; see Show your brand on your deposits.
Optional receipt linking
Venmo and X Money sellers can link the inbox that receives their payment receipts through a page Peer hosts. Linking is a separate step: peer.sell() and peer.sell.prepare() never invoke or require it. See Optional receipt linking.
Next step
Continue to the integration guide for signed and unsigned transaction paths, error recovery, and staging verification.