Skip to main content
This guide walks through deploying the zkp2p-contracts system to Base networks using Hardhat Deploy.

Prerequisites

Required Software

  • Node.js: Version 18 or higher
  • Yarn: Version 4+ (managed via Corepack)
  • Foundry: For Forge testing (optional)

Installation

Environment Setup

1. Create Environment File

Copy the default environment template:

2. Configure Environment Variables

Edit .env with your configuration:

API Key Sources

Never commit your .env file to version control. It contains sensitive private keys. The .env.default file uses test private keys only.

Deployment Process

Local Development

1. Start Local Hardhat Node

This starts a local Ethereum node at http://127.0.0.1:8545 with:
  • Deterministic accounts
  • Fast block mining
  • No deployment delay

2. Deploy to Local Node

In a separate terminal:
This executes all deployment scripts in sequence:
  1. 00_deploy_system.ts - Core registries, escrow, and orchestrator
  2. 01_deploy_unified_verifier.ts - Payment verification contracts
  3. 02-13_add_*_payment_method.ts - Payment platform configurations
  4. 14_deploy_v2_system.ts - V2 contracts (if applicable)

Base Sepolia Testnet

1. Fund Deployer Account

Get testnet ETH from a Base Sepolia faucet: Your deployer address is derived from TESTNET_DEPLOY_PRIVATE_KEY.

2. Deploy Contracts

Deployment artifacts are saved to:
Exported contract data:

3. Verify Contracts

This verifies all deployed contracts on Basescan with:
  • 5 second delay between verifications (avoids rate limiting)
  • Automatic constructor argument encoding
  • Retry logic for network issues

Base Mainnet Production

Production deployments are permanent and handle real funds. Triple-check all parameters before deploying.

1. Review Deployment Parameters

Check deployments/parameters.ts for production values:

2. Deploy to Base

This command:
  1. Deploys all contracts
  2. Configures permissions and ownership
  3. Transfers ownership to multisig
  4. Exports contract addresses to deployments/outputs/baseContracts.ts

3. Verify on Basescan

Uses 600ms delay between verifications for production rate limits.

Deployment Scripts

The deployment system uses numbered scripts that execute in order:

Core System (00-01)

00_deploy_system.ts - Deploys foundational contracts:
  • PaymentVerifierRegistry
  • PostIntentHookRegistry
  • RelayerRegistry
  • NullifierRegistry
  • EscrowRegistry
  • Escrow
  • Orchestrator
  • ProtocolViewer
01_deploy_unified_verifier.ts - Deploys verification layer:
  • SimpleAttestationVerifier
  • UnifiedPaymentVerifier

Payment Methods (02-13)

Each script adds a payment platform:
  • 02_add_venmo_payment_method.ts
  • 03_add_revolut_payment_method.ts
  • 04_add_cashapp_payment_method.ts
  • 05_add_wise_payment_method.ts
  • 06_add_mercadopago_payment_method.ts
  • 07_add_zelle_payment_methods.ts (Chase, BofA, Citi)
  • 08_add_paypal_payment_method.ts
  • 09_add_monzo_payment_method.ts
  • 10_add_n26_payment_method.ts
  • 11_add_alipay_payment_method.ts
  • 12_add_chime_payment_method.ts
  • 13_add_luxon_payment_method.ts

V2 System (14-16)

14_deploy_v2_system.ts - V2 architecture:
  • EscrowV2
  • OrchestratorV2
  • OrchestratorRegistry
  • RateManagerV1
  • ProtocolViewerV2
15_deploy_v2_periphery.ts - V2 utilities:
  • SignatureGatingPreIntentHook
  • AcrossBridgeHookV2
16_configure_v2_payment_methods.ts - V2 payment config

External Integrations (17)

17_deploy_pyth_oracle.ts - Price oracle:
  • PythOracleAdapter
  • ChainlinkOracleAdapter

Deployment Configuration

Network-Specific Parameters

Defined in deployments/parameters.ts:

Deployment Delays

To avoid nonce conflicts and ensure transaction confirmation:

Verifying Deployment

1. Check Contract Addresses

View deployed addresses:

2. Verify on Block Explorer

Navigate to Basescan:
  • Mainnet: https://basescan.org/address/<CONTRACT_ADDRESS>
  • Testnet: https://sepolia.basescan.org/address/<CONTRACT_ADDRESS>
Confirm:
  • Contract is verified (green checkmark)
  • Constructor arguments match
  • Owner is set correctly (multisig for production)

3. Test Core Functionality

Run deployment tests:
This executes:

4. Verify Ownership

Check that ownership was transferred:

Troubleshooting

Deployment Fails with “Nonce too low”

Cause: Transaction submitted with incorrect nonce Solution: Increase deployment delay in parameters.ts

”Insufficient funds” Error

Cause: Deployer account lacks ETH for gas Solution: Fund the deployer address:
Send ETH to this address from a faucet or your wallet.

Verification Fails with “Already verified”

Cause: Contract was verified in a previous run Solution: This is informational only. The contract is already verified.

”Contract source code already verified” on Basescan

Cause: Another deployment of identical code exists Solution: Basescan automatically verifies matching bytecode. No action needed.

Deployment Script Skipped

Cause: Script has skip function returning true Solution: Check the script’s skip conditions:
Modify the skip logic if you need to redeploy.

Post-Deployment Steps

1. Update Frontend Configuration

Update your frontend with new contract addresses:

2. Configure Subgraph

Update subgraph configuration with new addresses and start block numbers.

3. Set Up Monitoring

Configure monitoring for:
  • Contract events
  • Transaction failures
  • Ownership changes
  • Registry modifications

4. Document Deployment

Record deployment details:
  • Network and chain ID
  • Deployer address
  • Contract addresses
  • Deployment timestamp
  • Git commit hash
  • Constructor parameters

Advanced: Custom Deployment

Deploy Individual Contracts

Skip Specific Scripts

Edit the script’s skip function:

Test Deployment Locally First

Security Considerations

  • Private Keys: Never commit private keys. Use hardware wallets for production.
  • Multisig: Always transfer ownership to a multisig for production deployments.
  • Verification: Verify all contracts on Basescan before use.
  • Testing: Thoroughly test on Base Sepolia before mainnet deployment.
  • Audit: Have contracts audited before handling significant value.

Next Steps

After successful deployment:
  1. Verify contracts on Basescan
  2. Configure payment methods
  3. Set up relayers
  4. Monitor contract events
For production deployments, coordinate with the zkp2p team to ensure proper attestation service configuration and multisig setup.