Deployment Scripts
Foundry deployment scripts are located in thescript/ directory. Each script follows a consistent pattern and can be run in simulation mode before deploying.
Available Deployment Scripts
The repository contains deployment scripts for all major contracts:- HubPool:
DeployHubPool.s.sol- Deploys the central L1 HubPool contract - SpokePool Contracts: Chain-specific deployment scripts
DeployArbitrumSpokePool.s.solDeployOptimismSpokePool.s.solDeployPolygonSpokePool.s.solDeployZkSyncSpokePool.s.solDeployLineSpokePool.s.solDeployScrollSpokePool.s.sol- And many more…
- Adapters: Chain adapter deployment scripts
DeployArbitrumAdapter.s.solDeployOPAdapter.s.solDeployPolygonAdapter.s.solDeployUniversalAdapter.s.sol
- Utilities:
DeployMulticallHandler.s.solDeployDonationBox.s.solDeployAcrossEventEmitter.s.sol
Running Deployment Scripts
Basic Usage
Example: Deploy HubPool
Example: Deploy Arbitrum SpokePool
ZKSync Deployments
ZKSync requires special handling due to its custom compiler. Set theFOUNDRY_PROFILE environment variable:
Build Scripts
The repository supports building both EVM and SVM (Solana) contracts.EVM Build Commands
SVM Build Commands
The repository includes scripts for building Solana programs with both local toolchain and verified Docker builds.Local Toolchain Build
- Detects if
IS_TEST=trueenvironment variable is set - Builds with
--features testflag for test builds - Uses
anchor buildwith appropriate cargo options
Verified Docker Build
- Extracts Solana version from
Cargo.lock - Builds each program using
solana-verify build - Uses
solanafoundation/solana-verifiable-buildDocker image - Ensures reproducible builds for verification
Generate SVM Artifacts
Complete Build Commands
Extract Addresses Command
After deploying contracts with Foundry, extract deployed addresses to a consolidated file:- Reads from the
broadcast/folder (Foundry deployment artifacts) - Extracts deployed contract addresses using TypeScript
- Generates
/broadcast/deployed-addresses.jsonwith the latest deployed addresses - Useful for tracking deployments across multiple chains
/deployments/legacy-addresses.json.
Utility Scripts
Thescripts/ directory contains additional utility scripts:
Contract Analysis
Verification
Setup Scripts
Other Utilities
Pre-commit Hook
The repository includes a pre-commit hook that runs automatically:- Runs linting on staged files
- Ensures code quality before commits
- Configured via Husky in
package.json
Environment Variables
Deployment scripts require environment variables. Create a.env file:
Best Practices
- Always test in simulation mode first - Run scripts without
--broadcastto verify behavior - Use verbose output - The
-vvvvflag helps debug issues - Verify on-chain - Always include
--verifyflag for production deployments - Extract addresses - Run
yarn extract-addressesafter deployments to update the addresses file - Set correct profile - Use
FOUNDRY_PROFILE=zksyncfor ZKSync deployments - Environment setup - Source your
.envfile before running deployment scripts
Related
- Slither Static Analysis - Security analysis tool
- Testing Guide - Running tests
- Deployment Guide - Deploy contracts to networks