Skip to main content

Prerequisites

Before getting started, ensure you have the following installed:

Node.js 18+

Required for running the Hardhat development environment

Yarn 4

Package manager used for dependency management

Foundry

Required for forge command to run Foundry-based tests

Git

For cloning the repository and version control
The project uses Yarn 4 (Berry) with PnP. Make sure you have the correct version by running yarn --version.

Installation

1

Clone the Repository

Clone the zkp2p-v2-contracts repository from GitHub:
2

Install Dependencies

Install all project dependencies using Yarn:
This will install all necessary packages including:
  • Hardhat development framework
  • OpenZeppelin contracts
  • TypeChain for TypeScript bindings
  • Testing utilities (Chai, Mocha)
  • Foundry integration
3

Configure Environment Variables

Copy the default environment configuration and set your API keys:
Edit the .env file and add your keys:
.env
Never commit your .env file to version control. The .gitignore is already configured to exclude it.

Build the Project

The build process compiles Solidity contracts, generates TypeScript type definitions, and transpiles TypeScript code.
The yarn build command runs: yarn clean && yarn compile && yarn build:ts:latestThis ensures a clean build with updated TypeChain bindings.

Build Artifacts

After building, you’ll find:
  • artifacts/ - Compiled contract ABIs and bytecode
  • typechain/ - TypeScript type definitions for contracts
  • cache/ - Hardhat compilation cache
  • dist/ - Transpiled TypeScript files

Run Tests

ZKP2P includes comprehensive test coverage using both Hardhat and Foundry.

Hardhat Tests

Foundry Tests

Use yarn test:fast during development to skip compilation and run tests faster. Only use yarn test when you’ve made contract changes.

Test Coverage

Generate coverage reports to ensure comprehensive test coverage:
The project maintains high test coverage across all core components. Coverage reports are also published to Codecov.

Local Development

Run a local Hardhat node for development and testing.
1

Start Local Node

Launch a local Hardhat network in a separate terminal:
This starts a local Ethereum node at http://localhost:8545 with:
  • 10 prefunded test accounts
  • Instant mining (no block time)
  • Deterministic account generation
2

Deploy Contracts Locally

In another terminal, deploy the complete contract system:
This runs the deployment scripts in order:
  1. 00_deploy_system.ts - Core registries and system contracts
  2. 01_deploy_unified_verifier.ts - Unified payment verifier
  3. 02_add_venmo_payment_method.ts - Venmo configuration
  4. And subsequent payment method configurations…
3

Verify Deployment

Check that all contracts deployed successfully:
You should see deployment artifacts for:
  • Orchestrator.json
  • Escrow.json
  • UnifiedPaymentVerifier.json
  • PaymentVerifierRegistry.json
  • And other system contracts
Local deployment includes a USDC mock token for testing. In production deployments, the actual USDC token address is used.

Interact with Contracts

Once deployed locally, you can interact with contracts using Hardhat console or scripts.

Using Hardhat Console

Then interact with deployed contracts:

Create a Test Deposit

Here’s a complete example of creating a maker deposit:
Check out the test files in test/escrow/ and test/orchestrator/ for more comprehensive examples of contract interactions.

Deploy to Testnet

Deploy to Base Sepolia testnet for testing in a live environment.
1

Fund Deployment Account

Ensure your testnet private key account has ETH on Base Sepolia for gas fees. Get testnet ETH from:
2

Deploy to Base Sepolia

Run the deployment script:
This deploys the complete system to Base Sepolia testnet.
3

Verify Contracts

Verify contracts on Basescan for public transparency:
Verification uses a 600-second delay between submissions to avoid rate limiting.

Deploy to Production

Production deployments require extreme care! Ensure you:
  • Have thoroughly tested on testnet
  • Reviewed all deployment parameters
  • Verified multisig addresses
  • Have sufficient ETH for gas fees
  • Understand the implications of contract ownership

Deployment Parameters

Key parameters are configured in deployments/parameters.ts:

Hardhat Configuration

The project uses Hardhat with the following key settings:
hardhat.config.ts

Next Steps

Now that you have the contracts running locally, explore:

Architecture Guide

Deep dive into system design and component interactions

Contract Reference

Detailed API documentation for all contracts

Integration Examples

Learn how to integrate ZKP2P into your application

Architecture Guide

Understand the protocol architecture and components

Troubleshooting

Ensure you’re using the correct Node.js version (18+) and have the latest Hardhat installed:
The project uses viaIR optimization which can increase gas costs. For local testing, the gas limit is set to 100M:
Regenerate TypeChain types:
This occurs when non-TypeScript files exist in the deploy/ folder. The project is configured to skip .md, .mdx, and .txt files automatically.
For more help, check the GitHub Issues or join the community discussion.