Skip to main content
The @zkp2p/contracts-v2 package provides minimal, network-specific ABIs extracted from on-chain deployments.

Import ABIs

Import ABIs for specific contracts on a network:
import { Orchestrator, Escrow, UnifiedPaymentVerifier } from '@zkp2p/contracts-v2/abis/base';

// Use with ethers or viem
const orchestratorABI = Orchestrator;

Network-Specific ABIs

ABIs are organized by network to ensure compatibility:
import { 
  Orchestrator, 
  Escrow, 
  UnifiedPaymentVerifier,
  AcrossBridgeHook 
} from '@zkp2p/contracts-v2/abis/base';

Available Contract ABIs

Core Contracts

ContractDescription
OrchestratorMain protocol orchestrator for managing intents
EscrowHandles deposit escrow and fund management
UnifiedPaymentVerifierVerifies ZK proofs for payment validation

Hooks

ContractDescriptionNetworks
AcrossBridgeHookAcross Protocol bridge integrationBase mainnet only

Using with ethers.js

Read Contract Data

import { ethers } from 'ethers';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');

const orchestrator = new ethers.Contract(
  base.Orchestrator,
  Orchestrator,
  provider
);

// Read contract state
const intentExpiration = await orchestrator.intentExpirationPeriod();
const takerFee = await orchestrator.takerFee();
const escrowAddress = await orchestrator.escrow();

Write to Contracts

import { ethers } from 'ethers';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

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

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

// Signal intent
const tx = await orchestrator.signalIntent(
  depositId,
  amount,
  to,
  paymentMethodHash,
  currencyHash,
  priceLimit,
  paymentIdentifier,
  encryptedPaymentDetails
);

await tx.wait();
console.log('Intent signaled:', tx.hash);

Using with viem

Read Contract

import { createPublicClient, http } from 'viem';
import { base as baseChain } from 'viem/chains';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

const client = createPublicClient({
  chain: baseChain,
  transport: http(),
});

const intentExpiration = await client.readContract({
  address: base.Orchestrator,
  abi: Orchestrator,
  functionName: 'intentExpirationPeriod',
});

Write Contract

import { createWalletClient, custom } from 'viem';
import { base as baseChain } from 'viem/chains';
import { base } from '@zkp2p/contracts-v2/addresses';
import { Orchestrator } from '@zkp2p/contracts-v2/abis/base';

const client = createWalletClient({
  chain: baseChain,
  transport: custom(window.ethereum),
});

const hash = await client.writeContract({
  address: base.Orchestrator,
  abi: Orchestrator,
  functionName: 'signalIntent',
  args: [
    depositId,
    amount,
    to,
    paymentMethodHash,
    currencyHash,
    priceLimit,
    paymentIdentifier,
    encryptedPaymentDetails,
  ],
});

Direct JSON Import

For bundle size optimization, import JSON files directly:
import OrchestratorABI from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';
import EscrowABI from '@zkp2p/contracts-v2/abis/base/Escrow.json';

const orchestrator = new ethers.Contract(
  address,
  OrchestratorABI,
  provider
);

Import All ABIs for a Network

Import all ABIs as a single object:
import * as baseAbis from '@zkp2p/contracts-v2/abis/base';

console.log(baseAbis.Orchestrator);
console.log(baseAbis.Escrow);
console.log(baseAbis.UnifiedPaymentVerifier);

TypeScript Types

For TypeScript contract types, use the types export:
import type { Orchestrator, Escrow } from '@zkp2p/contracts-v2/types';

// Use types for type-safe contract interactions
type OrchestratorContract = Orchestrator;

ABI Structure

ABIs follow the standard Ethereum ABI format:
type ABI = Array<{
  type: 'function' | 'event' | 'error' | 'constructor';
  name?: string;
  inputs?: Array<{ name: string; type: string; internalType?: string }>;
  outputs?: Array<{ name: string; type: string; internalType?: string }>;
  stateMutability?: 'pure' | 'view' | 'nonpayable' | 'payable';
}>;

Next Steps

Contract Addresses

Access deployed contract addresses

Constants

Use protocol constants

Utilities

Use protocol utility functions

Build docs developers (and LLMs) love