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
| Service | Purpose | Get API Key |
|---|---|---|
| Alchemy | RPC provider for Base networks | alchemy.com |
| Basescan | Contract verification on Base | basescan.org/apis |
| Etherscan | Contract verification (legacy) | etherscan.io/apis |
| Infura | Alternative RPC provider | infura.io |
Deployment Process
Local Development
1. Start Local Hardhat Node
http://127.0.0.1:8545 with:
- Deterministic accounts
- Fast block mining
- No deployment delay
2. Deploy to Local Node
In a separate terminal:00_deploy_system.ts- Core registries, escrow, and orchestrator01_deploy_unified_verifier.ts- Payment verification contracts02-13_add_*_payment_method.ts- Payment platform configurations14_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 fromTESTNET_DEPLOY_PRIVATE_KEY.
2. Deploy Contracts
3. Verify Contracts
- 5 second delay between verifications (avoids rate limiting)
- Automatic constructor argument encoding
- Retry logic for network issues
Base Mainnet Production
1. Review Deployment Parameters
Checkdeployments/parameters.ts for production values:
2. Deploy to Base
- Deploys all contracts
- Configures permissions and ownership
- Transfers ownership to multisig
- Exports contract addresses to
deployments/outputs/baseContracts.ts
3. Verify on Basescan
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.ts03_add_revolut_payment_method.ts04_add_cashapp_payment_method.ts05_add_wise_payment_method.ts06_add_mercadopago_payment_method.ts07_add_zelle_payment_methods.ts(Chase, BofA, Citi)08_add_paypal_payment_method.ts09_add_monzo_payment_method.ts10_add_n26_payment_method.ts11_add_alipay_payment_method.ts12_add_chime_payment_method.ts13_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 indeployments/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>
- Contract is verified (green checkmark)
- Constructor arguments match
- Owner is set correctly (multisig for production)
3. Test Core Functionality
Run deployment tests: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 inparameters.ts
”Insufficient funds” Error
Cause: Deployer account lacks ETH for gas Solution: Fund the deployer address: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 hasskip function returning true
Solution: Check the script’s skip conditions:
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
Next Steps
After successful deployment:For production deployments, coordinate with the zkp2p team to ensure proper attestation service configuration and multisig setup.