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 testsGit
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
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
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 bytecodetypechain/- TypeScript type definitions for contractscache/- Hardhat compilation cachedist/- Transpiled TypeScript files
Run Tests
ZKP2P includes comprehensive test coverage using both Hardhat and Foundry.Hardhat Tests
Foundry Tests
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.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
Deploy Contracts Locally
In another terminal, deploy the complete contract system:This runs the deployment scripts in order:
00_deploy_system.ts- Core registries and system contracts01_deploy_unified_verifier.ts- Unified payment verifier02_add_venmo_payment_method.ts- Venmo configuration- And subsequent payment method configurations…
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
Create a Test Deposit
Here’s a complete example of creating a maker deposit:Deploy to Testnet
Deploy to Base Sepolia testnet for testing in a live environment.Fund Deployment Account
Ensure your testnet private key account has ETH on Base Sepolia for gas fees. Get testnet ETH from:
Deploy to Base Sepolia
Run the deployment script:This deploys the complete system to Base Sepolia testnet.
Deploy to Production
Deployment Parameters
Key parameters are configured indeployments/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
Compilation errors with Solidity 0.8.18
Compilation errors with Solidity 0.8.18
Ensure you’re using the correct Node.js version (18+) and have the latest Hardhat installed:
Out of gas errors during tests
Out of gas errors during tests
The project uses
viaIR optimization which can increase gas costs. For local testing, the gas limit is set to 100M:TypeChain types not found
TypeChain types not found
Regenerate TypeChain types:
Deployment scripts fail with 'skip' function error
Deployment scripts fail with 'skip' function error
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.