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, and embed the Peer extension onramp. The current npm release is 0.1.0 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 wants to open the Peer extension onrampOnramp IntegrationCovers peerExtensionSdk and the extension deeplink flow
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

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 is a peer dependency. react >= 16.8.0 is an optional peer dependency that is only required for @zkp2p/sdk/react.

Architecture

The SDK is built around RPC-first reads 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.
  • 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 onramp deeplink helpersOnramp Integration
client.indexerAdvanced deposit, intent, and fulfillment queriesClient 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

Entry points

  • Import the core SDK from @zkp2p/sdk
  • Import hooks from @zkp2p/sdk/react
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,
runtimeEnv: 'production',
apiKey: 'YOUR_API_KEY',
});

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 and V2-first routing defaults

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.

Help?

If you run into issues, join our Discord.