Skip to content

zkp2p/zkp2p-client-sdk

Repository files navigation

zkp2p-client-sdk

npm version GitHub Release License: MIT TypeScript

Browser-first TypeScript SDK for integrating ZKP2P into web applications. ZKP2P enables trustless peer-to-peer fiat-to-crypto exchanges using zero-knowledge proofs, allowing users to on-ramp from traditional payment platforms directly to cryptocurrency without intermediaries.

Features

  • Multi-Platform Support: Integrate with Wise, Venmo, Revolut, PayPal, and more
  • 35+ Fiat Currencies: Support for USD, EUR, GBP, and many other currencies
  • Type-Safe: Full TypeScript support with comprehensive type definitions
  • Browser Extension Integration: Seamless integration with the Peerauth browser extension for proof generation
  • Chain Agnostic: Support for Base and other EVM-compatible chains
  • Proven Architecture: Built on the battle-tested core from the React Native SDK

Installation

npm install @zkp2p/client-sdk viem

Quick Start (V3)

import { Zkp2pClient } from '@zkp2p/client-sdk';
import { createWalletClient, custom } from 'viem';
import { base } from 'viem/chains';

// Create a viem wallet client (browser)
const walletClient = createWalletClient({ chain: base, transport: custom(window.ethereum) });

// Initialize the V3 client (Orchestrator + Attestation + ProtocolViewer)
const client = new Zkp2pClient({ walletClient, chainId: base.id, runtimeEnv: 'production', baseApiUrl: 'https://api.zkp2p.xyz', apiKey: 'YOUR_API_KEY' });

// Quote (HTTP)
const quotes = await client.getQuote({
  paymentPlatforms: ['wise'],
  fiatCurrency: 'USD',
  user: '0xYourAddress',
  recipient: '0xRecipientAddress',
  destinationChainId: base.id,
  destinationToken: '0xUSDC',
  amount: '100',
});

// Signal intent (Orchestrator) with ergonomic inputs
await client.signalIntent({
  depositId: 1n,
  amount: 1000000n,
  toAddress: '0xRecipientAddress',
  processorName: 'wise',
  fiatCurrencyCode: 'USD',
  conversionRate: 1000000n,
  payeeDetails: '0xHashedOnchainId',
});

// Fulfill via Attestation Service (proof is a string)
await client.fulfillIntent({
  intentHash: '0xIntent',
  zkTlsProof: JSON.stringify(proofObj),
  platform: 'wise',
  actionType: 'payment',
  amount: '1000000',
  timestampMs: String(Date.now()),
  fiatCurrency: '0xUSD_BYTES32',
  conversionRate: '1000000',
  payeeDetails: '0xHashedOnchainId',
  timestampBufferMs: '600000',
});

Documentation

  • Primary Package: See packages/client-sdk/README.md for comprehensive integration documentation
  • Examples: Check the examples/ directory for:
    • Vite React application walkthrough
    • Node.js script for fetching quotes
    • Browser E2E demo with extension integration
    • Orchestrator pattern implementation

Supported Platforms and Currencies

Payment Platforms

wise, venmo, revolut, cashapp, mercadopago, zelle, paypal, monzo

Fiat Currencies

AED, ARS, AUD, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, JPY, KES, MXN, MYR, NOK, NZD, PHP, PLN, RON, SAR, SEK, SGD, THB, TRY, UGX, USD, VND, ZAR

Browser Extension Integration

The SDK includes a browser-only extension helper for Peerauth integration:

import { PeerauthExtension } from '@zkp2p/client-sdk/extension';

const ext = new PeerauthExtension({
  onVersion: v => console.log('Extension version:', v)
});

Note: For SSR frameworks, import dynamically or guard usage with typeof window !== 'undefined'.

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

Releases


Development

Setup

cd packages/client-sdk
npm ci
npm run build

Testing

cd packages/client-sdk
npm test

Maintainer Notes

  • CI/CD: Automated typecheck, lint, build, and tests on PRs
  • Publishing: Automatic npm publish on v* tags via GitHub Actions
  • Releases: Use npx release-it --ci locally to bump version and generate changelog

About

Browser-first TypeScript SDK for ZKP2P - trustless fiat-to-crypto exchanges using zero-knowledge proofs

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •