Contract Verification
Relevant source files
The following files were used as context for generating this wiki page:
Contract verification in the Canon Guard project ensures that the deployed bytecode on-chain matches the local source code, providing transparency and security for the multisig solution. This process is integrated into the deployment pipeline, leveraging Foundry's forge script capabilities to automate verification across different networks like Ethereum and Optimism.
Sources: README.md:1-10, CLAUDE.md:10-15
Deployment and Verification Workflow
Verification is handled as a secondary step immediately following the deployment of smart contracts. The project uses Foundry's broadcast mechanism to record transaction data and automatically trigger the verification process on block explorers such as Etherscan or Optimistic Etherscan.
Verification Environment Setup
Before initiating verification, the environment must be configured with the necessary API keys and network RPCs. These are managed via an .env file and sourced into the shell session.
# Sourcing environment variables for verification
source .env
Sources: README.md:65-68, package.json:16-17
Verification Configuration
The foundry.toml file contains the configuration for the verification providers. It specifies the Etherscan API keys required for different chains to authenticate the verification requests.
| Chain | Config Key | Environment Variable |
|---|---|---|
| Ethereum | etherscan.ethereum | ${ETHERSCAN_API_KEY} |
| Optimism | etherscan.optimism | ${ETHERSCAN_API_KEY} |
Sources: foundry.toml:34-36
Automated Verification via Scripts
The project utilizes yarn scripts defined in package.json to streamline the deployment and verification of the CanonGuard contracts. These scripts utilize the --verify flag in forge script, which instructs Foundry to submit the source code to the relevant explorer.
Execution Flow
The following diagram illustrates the automated flow from script execution to on-chain verification:
The flow ensures that any contract deployed through the standard deployment scripts is simultaneously submitted for verification.
Sources: README.md:83-85, package.json:16-17
Supported Networks
Verification is pre-configured for two primary networks through the project's task runner:
- Ethereum Mainnet: Verified via the
deploy:ethereum:canon-guardscript. - Optimism: Verified via the
deploy:optimism:canon-guardscript.
Sources: package.json:16-17, CLAUDE.md:52-55
Technical Verification Requirements
For verification to be successful, the compilation environment must remain consistent with the deployment environment. Canon Guard uses specific Solidity compiler versions and optimization settings.
Compiler Settings
| Setting | Value | Source |
|---|---|---|
| Solidity Version | 0.8.30 | foundry.toml:14 |
| Optimizer Runs | 10,000 | foundry.toml:16 |
| EVM Version | prague | foundry.toml:17 |
| Via IR | true (for optimized profiles) | foundry.toml:20 |
Deployment Persistence
The results of the verification and deployment are stored locally in the ./broadcast directory. This directory contains the JSON files that record the contract addresses and constructor arguments, which are essential for manual verification if the automated process fails.
Sources: README.md:83, foundry.toml:21
Conclusion
Contract verification in Canon Guard is a critical component of its security-first architecture. By automating the verification process through Foundry scripts and maintaining strict compiler configurations in foundry.toml, the project ensures that the "Safer Safe" mechanisms—including the SafeEntrypoint and various ActionBuilders—are fully transparent and auditable by the community.