Optimism Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Optimism Deployment refers to the process and configuration required to deploy the Canon Guard multisig solution to the Optimism L2 network. Canon Guard (also referred to as "Safer Safe") enhances standard Safe accounts by integrating fully on-chain Actions contracts and dynamic timelocks.
The deployment on Optimism utilizes the Foundry toolchain to ensure deterministic addresses and verified contract code, providing a secure environment for recurring transactions with minimal reliance on external services.
Sources: README.md:1-5, CLAUDE.md:3-8
Deployment Architecture
The deployment on Optimism mirrors the Ethereum mainnet structure, focusing on several core components that must be instantiated for the system to function. These include the main entrypoint, the guard mechanisms, and various action builders.
Core Components for Deployment
| Component | Description |
|---|---|
| SafeEntrypoint | The primary contract allowing transaction execution on a Safe with time delays. |
| CanonGuard | The guard contract that ensures transactions follow the defined entrypoint logic. |
| Action Builders | Implementation contracts for specific transaction patterns (e.g., SimpleActions, CappedTokenTransfers). |
| ActionHub | A management layer for handling different action builders and their respective limits. |
Sources: CLAUDE.md:12-22, test/invariants/PROPERTIES.md:5-11
Deployment Flow
The following diagram illustrates the sequence of actions taken during an Optimism deployment using the project's scripts.
The deployment process relies on forge script to execute the DeployCanonGuard logic, which broadcasts transactions to the network and verifies them using the provided API keys.
Sources: README.md:68-91, package.json:21-22
Environment Configuration
Successful deployment requires specific environment variables and Foundry settings tailored for the Optimism network.
RPC and Etherscan Settings
The project uses foundry.toml to define the network-specific endpoints and verification keys.
| Variable | Description | Source |
|---|---|---|
OPTIMISM_RPC | The RPC URL for the Optimism network. | foundry.toml:42 |
ETHERSCAN_API_KEY | The key used for contract verification on Optimism. | foundry.toml:46 |
OPTIMISM_DEPLOYER_NAME | The name of the encrypted keystore account in Foundry. | README.md:82 |
Solidity Compiler Configuration
Deployments on Optimism utilize the following compiler settings:
- Solidity Version: 0.8.30
- Optimizer Runs: 10,000
- EVM Version: Prague
- Via IR: Enabled for optimized profiles to reduce bytecode size and gas costs.
Sources: foundry.toml:14-25, CLAUDE.md:52-57
Execution Commands
The project provides standardized yarn scripts to trigger the deployment pipeline. These scripts wrap complex forge script commands into simple interfaces.
Primary Deployment Command
To deploy the full suite to Optimism:
yarn deploy:optimism:canon-guard
This command sources the .env file and executes the DeployCanonGuard script with the following flags:
--rpc-url optimism: Uses the Optimism RPC defined infoundry.toml.--account $OPTIMISM_DEPLOYER_NAME: Uses the encrypted keystore for signing.--broadcast: Sends the transactions to the network.--verify: Triggers contract verification on the block explorer.
Sources: package.json:22, README.md:88-90
Component-Specific Deployments
Additional scripts are available for deploying individual modules:
yarn deploy:optimism:entrypoint: Deploys only the Safe entrypoint.yarn deploy:optimism:safer-safe: Deploys the safer-safe wrapper/guard.
Sources: CLAUDE.md:46-47
Deployment Verification and Storage
Once the deployment script completes, the results are stored locally for reference and further integration.
- Broadcast Logs: Details of the transactions are stored in the
./broadcastdirectory. - Deterministic Addresses: The project uses
CREATE3for deployment to ensure that contract addresses remain consistent across different chains (Ethereum and Optimism). - NPM Export: After deployment, TypeScript interfaces can be generated and published to NPM for frontend or service integration using TypeChain.
Sources: README.md:92, CLAUDE.md:68, README.md:97-105
Conclusion
Deploying Canon Guard to Optimism enables high-security multisig operations with the cost-efficiency of an L2. By leveraging Foundry's scripting capabilities and CREATE3 deterministic deployments, the project ensures that the security properties verified in the invariant tests—such as cap limits, timing constraints, and approval validities—are consistently applied to the Optimism network.
Sources: test/invariants/PROPERTIES.md:13-33, CLAUDE.md:68-72