Skip to main content
The @zkp2p/contracts-v2/paymentMethods module provides unified payment method configurations including payment method hashes, supported currencies, and provider hashes from on-chain deployments.

Import Payment Methods

Import payment method configurations for a specific network:
import { base } from '@zkp2p/contracts-v2/paymentMethods';

// Access specific payment method
const venmoConfig = base.methods.venmo;
console.log('Payment Method Hash:', venmoConfig.paymentMethodHash);
console.log('Supported Currencies:', venmoConfig.currencies);

Network-Specific Payment Methods

import { base } from '@zkp2p/contracts-v2/paymentMethods';

// Access payment methods
const venmo = base.methods.venmo;
const revolut = base.methods.revolut;
const wise = base.methods.wise;
const cashapp = base.methods.cashapp;

console.log('Network:', base.network);
console.log('Chain ID:', base.chainId);

Payment Method Configuration

Each payment method contains:
interface PaymentMethodConfig {
  paymentMethodHash: string;        // Keccak256 hash of payment method name
  currencies: string[];             // Array of supported currency hashes
  timestampBuffer: number;          // Buffer time in seconds
  providerHashes: string[];         // Array of provider email domain hashes
}

Available Payment Methods

Venmo

import { base } from '@zkp2p/contracts-v2/paymentMethods';

const venmoConfig = base.methods.venmo;
console.log(venmoConfig);
// {
//   paymentMethodHash: "0x9026...",
//   currencies: ["0xc4ae..."], // USD
//   timestampBuffer: 30,
//   providerHashes: ["0x..."]
// }
Venmo only supports USD currency and is available in the United States.

Revolut

import { base } from '@zkp2p/contracts-v2/paymentMethods';

const revolutConfig = base.methods.revolut;
console.log('Supported currencies:', revolutConfig.currencies.length);
// 24 currencies supported
Revolut supports 24+ currencies including USD, EUR, GBP, AUD, CAD, and more.

Cash App

import { base } from '@zkp2p/contracts-v2/paymentMethods';

const cashappConfig = base.methods.cashapp;
console.log(cashappConfig.paymentMethodHash);
// "0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d"

Wise

import { base } from '@zkp2p/contracts-v2/paymentMethods';

const wiseConfig = base.methods.wise;
console.log('Currencies:', wiseConfig.currencies.length);
// Multiple currencies supported

Working with Payment Method Hashes

Get Payment Method Hash

import { base } from '@zkp2p/contracts-v2/paymentMethods';

function getPaymentMethodHash(methodName: string): string | undefined {
  return base.methods[methodName]?.paymentMethodHash;
}

const venmoHash = getPaymentMethodHash('venmo');
// "0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268"

Check Currency Support

import { base } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

function supportsCurrency(
  methodName: string, 
  currencyHash: string
): boolean {
  const method = base.methods[methodName];
  return method?.currencies.includes(currencyHash) ?? false;
}

// Check if Venmo supports USD
const venmoSupportsUSD = supportsCurrency('venmo', Currency.USD);
console.log('Venmo supports USD:', venmoSupportsUSD); // true

// Check if Venmo supports EUR
const venmoSupportsEUR = supportsCurrency('venmo', Currency.EUR);
console.log('Venmo supports EUR:', venmoSupportsEUR); // false

Verify Provider Hash

import { base } from '@zkp2p/contracts-v2/paymentMethods';

function hasProviderHash(
  methodName: string,
  providerHash: string
): boolean {
  const method = base.methods[methodName];
  return method?.providerHashes.includes(providerHash) ?? false;
}

const providerHash = "0x...";
const isValid = hasProviderHash('venmo', providerHash);

Helper Functions

Get All Payment Methods

import { base } from '@zkp2p/contracts-v2/paymentMethods';

function getAllPaymentMethods() {
  return Object.keys(base.methods);
}

const methods = getAllPaymentMethods();
console.log('Available methods:', methods);
// ["venmo", "revolut", "cashapp", "wise", ...]

Find Methods by Currency

import { base } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

function findMethodsByCurrency(currencyHash: string): string[] {
  return Object.entries(base.methods)
    .filter(([_, config]) => config.currencies.includes(currencyHash))
    .map(([name]) => name);
}

const usdMethods = findMethodsByCurrency(Currency.USD);
console.log('USD payment methods:', usdMethods);
// ["venmo", "revolut", "cashapp", "wise", ...]

Using in Smart Contract Calls

Signal Intent with Payment Method

import { ethers } from 'ethers';
import { base as addresses } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';
import { base as paymentMethods } from '@zkp2p/contracts-v2/paymentMethods';
import { Currency } from '@zkp2p/contracts-v2/utils/protocolUtils';

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

const orchestrator = new ethers.Contract(
  addresses.Orchestrator,
  Orchestrator,
  signer
);

// Get payment method hash for Venmo
const venmoHash = paymentMethods.methods.venmo.paymentMethodHash;

const tx = await orchestrator.signalIntent(
  depositId,
  amount,
  to,
  venmoHash,           // Payment method hash
  Currency.USD,        // Currency hash
  priceLimit,
  paymentIdentifier,
  encryptedPaymentDetails
);

await tx.wait();

Type Definitions

interface PaymentMethodConfig {
  paymentMethodHash: string;
  currencies: string[];
  timestampBuffer: number;
  providerHashes: string[];
}

interface NetworkPaymentMethods {
  network: string;
  chainId?: number | string;
  generatedAt: string;
  methods: Record<string, PaymentMethodConfig>;
}

Direct JSON Import

For bundle size optimization:
import basePaymentMethods from '@zkp2p/contracts-v2/paymentMethods/base.json';

console.log(basePaymentMethods.methods.venmo);

Next Steps

Utilities

Use protocol utility functions

Constants

Access protocol constants

Build docs developers (and LLMs) love