SDK Overview
Choose the right SDK
Peer publishes two TypeScript SDKs with deliberately different levels of abstraction. They are complementary, not interchangeable.
| Package | Use it when | Product boundary |
|---|---|---|
@zkp2p/cash | Your product needs one opinionated crypto-to-fiat cash-out flow | Offramp only. The cashing-out user is the maker; every order settles into Base USDC, uses the live Chainlink rate at fill with zero spread, and exposes a small resumable lifecycle. It does not expose buyer operations, custom pricing, vaults, or protocol configuration. |
@zkp2p/sdk | You are building directly on the Peer protocol | General-purpose maker and taker primitives: deposits, intents, fulfillment, quotes, proofs, vaults, rate managers, hooks, referrals, and API-backed flows. Your application owns the workflow and protocol choices. |
If cash-out is the whole job, start with the Peer Cash SDK overview. Use this page when you need the broader protocol surface or want to compose a custom flow.
What this does
@zkp2p/sdk is the TypeScript SDK for building with Peer. Use it to manage deposits, signal and fulfill intents, access quote APIs, work with vault and rate-manager flows, run Peer extension headless metadata capture, request identity attestations, manage referral accounts, and integrate Seller Autopilot. The current release is 0.9.0 and is published under the MIT license.
V3 buying capacity is separate from quote discovery. Read capacity from the configured Curator environment and treat OrchestratorV3 admission as authoritative. Legacy tier exports can remain in an SDK release for V2 compatibility, but new integrations must not use them to predict V3 admission.
Who is this for?
| You are building... | Start here | Why |
|---|---|---|
| A liquidity provider or off-ramp dashboard | Offramp Integration | Covers deposit creation, funding, and deposit management end to end |
| An app that needs Peer extension payment capture | Onramp Integration | Covers peerExtensionSdk and the extension's headless metadata bridge |
| A custom taker flow, backend, or internal tool | Client Reference | Covers Zkp2pClient, intents, quotes, vaults, helpers, and API-backed flows |
| A React app | React Hooks | Covers the @zkp2p/sdk/react hook layer for transaction UX |
| A React Native app | React Native SDK | Covers mobile WebView auth, Buyer TEE proofs, taker registration, Seller Autopilot, and mobile endpoint defaults |
Installation
Install the core SDK with viem. Add react only if you plan to use the hooks package.
npm install @zkp2p/sdk viem
# or
yarn add @zkp2p/sdk viem
# or
pnpm add @zkp2p/sdk viem
# or
bun add @zkp2p/sdk viem
For hooks:
npm install react
# or
yarn add react
# or
pnpm add react
# or
bun add react
viem ^2.37.3 is a peer dependency. react >= 16.8.0 is an optional peer dependency that is only required for @zkp2p/sdk/react. For Node runtimes, the published package declares node >= 22.
For React Native, use the mobile package instead:
yarn add @zkp2p/zkp2p-react-native-sdk@0.4.4 viem@2.52.2 react-native-webview@13.16.1 @react-native-async-storage/async-storage@3.1.1 @preeternal/react-native-cookie-manager@6.3.3
See React Native SDK for the full peer-version matrix, iOS setup, and proof-only startup flow.
Architecture
The SDK is built around RPC-first reads, V2 contract routing, and contract-safe write helpers.
- Common reads such as
getDeposits(),getDeposit(),getIntents(), andgetIntent()use ProtocolViewer and on-chain state first, which helps avoid indexer lag for core flows. - Contract routing targets the EscrowV2/OrchestratorV2 stack. Legacy V1 escrow/orchestrator fallbacks are not part of the current client routing surface.
- Advanced history and filtering live behind
client.indexer.*, which gives you GraphQL-backed access to richer search, pagination, and fulfillment records. - Write methods are split between deposit management, intent operations, and vault/rate-manager flows, with prepared-transaction support for relayers and smart accounts.
Module map
| Module | What it covers | Start here |
|---|---|---|
Zkp2pClient | The canonical SDK client for reads, writes, and API-backed flows | Client Reference |
peerExtensionSdk | Peer extension detection, connection, and headless metadata bridge helpers | Onramp Integration |
client.indexer | Advanced deposit, intent, and fulfillment queries | Client Reference |
| Seller Autopilot | Seller credential upload, PayPal forwarding confirmation, OAuth credential upload, status, and payment verification helpers | Client Reference |
| Referral account APIs | Public referral reads, code lookup, bearer writes, and EIP-712 wallet-signature writes | Client Reference |
| API and attestation helpers | Orderbook, deposit bundle, payee validation, Venmo/PayPal/Wise identity attestation, and buyer TEE helpers | Client Reference |
| Contract helpers | getContracts, getRateManagerContracts, getPaymentMethodsCatalog, getGatingServiceAddress | Client Reference |
| Currency and payment helpers | currencyInfo, resolveFiatCurrencyBytes32, payment-method hash helpers | Client Reference |
| Attribution and fee helpers | ERC-8021 helpers and referrer fee validation utilities | Client Reference |
| React hooks | Transaction-oriented hooks for deposits, intents, and vaults | React Hooks |
| React Native SDK | Mobile provider, useZkp2p(), Buyer TEE proof preparation, taker registration, and Seller Autopilot | React Native SDK |
Entry points
- Import the core SDK from
@zkp2p/sdk - Import hooks from
@zkp2p/sdk/react - Import the mobile provider, hook, and client from
@zkp2p/zkp2p-react-native-sdk
OfframpClient is a re-export alias of Zkp2pClient. Both names work, but Zkp2pClient is the canonical class name used by the published typings and the docs on this page.
Quick start
import { Zkp2pClient } from "@zkp2p/sdk";
import { createWalletClient, custom } from "viem";
import { base } from "viem/chains";
const walletClient = createWalletClient({
chain: base,
transport: custom(window.ethereum),
});
const client = new Zkp2pClient({
walletClient,
chainId: base.id,
});
const deposits = await client.getDeposits();
console.log(deposits.length);
Runtime and network selection
The current SDK docs assume Base. Deployment selection is controlled by chainId plus runtimeEnv.
| Target | chainId | runtimeEnv | Notes |
|---|---|---|---|
| Base production | 8453 | production | Default customer-facing deployment |
| Base preproduction | 8453 | preproduction | Production contracts with preproduction services |
| Base staging | 8453 | staging | Staging services with V2 contract routing |
Recommended starting points
If you are new to the SDK, use this order:
- Read Offramp Integration or Onramp Integration for an end-to-end flow.
- Use Client Reference to look up concrete methods, request shapes, and helper exports.
- Use React Hooks if you want component-level loading, error, and transaction state.
- Use React Native SDK for mobile WebView auth, Buyer TEE, identity registration, and Seller Autopilot.
Help?
If you run into issues, join our Discord.