Skip to main content

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.2 and is published under the MIT license.

Who is this for?

You are building...Start hereWhy
A liquidity provider or off-ramp dashboardOfframp IntegrationCovers deposit creation, funding, and deposit management end to end
An app that needs Peer extension payment captureOnramp IntegrationCovers peerExtensionSdk and the extension 0.6.0 headless metadata bridge
A custom taker flow, backend, or internal toolClient ReferenceCovers Zkp2pClient, intents, quotes, vaults, helpers, and API-backed flows
A React appReact HooksCovers the @zkp2p/sdk/react hook layer for transaction UX
A React Native appReact Native SDKCovers 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
note

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(), and getIntent() 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.x 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

ModuleWhat it coversStart here
Zkp2pClientThe canonical SDK client for reads, writes, and API-backed flowsClient Reference
peerExtensionSdkPeer extension detection, connection, and headless metadata bridge helpersOnramp Integration
client.indexerAdvanced deposit, intent, and fulfillment queriesClient Reference
Seller AutopilotSeller credential upload, PayPal forwarding confirmation, OAuth credential upload, status, and payment verification helpersClient Reference
API and attestation helpersOrderbook, deposit bundle, payee validation, Venmo/PayPal/Wise identity attestation, and buyer TEE helpersClient Reference
Contract helpersgetContracts, getRateManagerContracts, getPaymentMethodsCatalog, getGatingServiceAddressClient Reference
Currency and payment helperscurrencyInfo, resolveFiatCurrencyBytes32, payment-method hash helpersClient Reference
Attribution and fee helpersERC-8021 helpers and referrer fee validation utilitiesClient Reference
React hooksTransaction-oriented hooks for deposits, intents, and vaultsReact Hooks
React Native SDKMobile provider, useZkp2p(), Buyer TEE proof preparation, taker registration, and Seller AutopilotReact 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
Naming note

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.

TargetchainIdruntimeEnvNotes
Base production8453productionDefault customer-facing deployment
Base preproduction8453preproductionProduction contracts with preproduction services
Base staging8453stagingStaging services with V2 contract routing

If you are new to the SDK, use this order:

  1. Read Offramp Integration or Onramp Integration for an end-to-end flow.
  2. Use Client Reference to look up concrete methods, request shapes, and helper exports.
  3. Use React Hooks if you want component-level loading, error, and transaction state.
  4. Use React Native SDK for mobile WebView auth, Buyer TEE, identity registration, and Seller Autopilot.

Help?

If you run into issues, join our Discord.