SDK Overview
What this does
@zkp2p/sdk is the TypeScript SDK for building with Peer. Use it to manage deposits, signal and fulfill intents, access quote and taker-tier APIs, work with vault and rate-manager flows, run Peer extension headless metadata capture, request identity attestations, and integrate Seller Autopilot. The current npm release is 0.5.7 and is published under the MIT license.
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 0.6.0 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.2 viem@2.52.2 react-native-webview@13.16.1 @react-native-async-storage/async-storage@3.1.1 @react-native-cookies/cookies@6.2.1
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
0.5.xclient 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 |
| 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.