Overview
Cannon provides:- Deterministic CREATE2 deployments
- Deployment manifest with ABIs and addresses
- Integration with existing CoW Protocol packages
- Versioned package management
Building the Cannon Package
Build the package
Run the Cannon build command:Or using pnpm directly:This will:
- Recompile the Solidity contracts as needed
- Generate a deployment manifest
- Include Solidity input JSON
- Include default settings and ABIs
- Calculate predicted deployment addresses
Cannonfile Configuration
Thecannonfile.toml defines the deployment configuration:
cannonfile.toml
Key Configuration Options
Package Dependencies
cow-settlement package to get the settlement contract address.
CREATE2 Deployment
create2 = true- Enables deterministic CREATE2 deploymentsalt- Salt value for CREATE2 address calculation- Ensures same address across all networks
Constructor Arguments
Deployment Strategy
Publishing the Package
Check version
Verify the version in Update if necessary before publishing.
cannonfile.toml is correct:Publish to Cannon registry
You need:This executes:Where:
- An EOA with permission on the
cow-settlementpackage - 0.0025 ETH + gas on Optimism Mainnet
--chain-id 13370- Anvil network used by Cannon to prepare packages--registry-chain-id 10- Optimism Mainnet where the registry is deployed
Select network and provide key
You will be prompted for:
- Publishing network - Select “Optimism”
- Private key - Enter the private key of the authorized account
Record deployment artifacts
After publishing, record the deployment data:This runs:If you don’t see changes in the
cannon/ directory, you may need to run this command manually.Bump version
After successful publishing, bump the patch version in This ensures the next publish uses a new version.
cannonfile.toml:Package Scripts
Thepackage.json defines several useful scripts:
package.json
Script Details
| Script | Description |
|---|---|
build | Alias for build:cannon |
build:cannon | Builds Cannon package with --wipe flag |
cannon:publish | Publishes package and records artifacts |
cannon:record | Exports deployment data to JSON files |
CREATE2 Deployment
CREATE2 ensures the HooksTrampoline contract has the same address on all networks:-
Deterministic address - The address is calculated from:
- Deployer address
- Salt value
- Contract bytecode and constructor arguments
-
Benefits:
- Same address across all EVM networks
- Predictable before deployment
- Easier integration and verification
-
Salt value:
Change this to get a different address if needed.
Integration with CoW Protocol
The HooksTrampoline package integrates with the CoW Protocol ecosystem:Settlement Contract Dependency
cow-settlement to get the settlement address.
Constructor Dependency
cow-settlement package.
Deployment to Production Networks
Actual deployment to production networks is handled through the cowprotocol/deployments repository:-
Staging deployment:
- Test on testnets (Sepolia, Goerli)
- Verify contract behavior
- Run integration tests
-
Production deployment:
- Deploy to mainnet networks (Ethereum, Gnosis Chain, Arbitrum, etc.)
- Verify contracts on Etherscan
- Update documentation with addresses
-
Package versioning:
- Follow semantic versioning
- Tag releases in git
- Publish to Cannon registry
Browsing Deployed Contracts
View deployed contracts and packages:- Deployments repository: github.com/cowprotocol/deployments
- Cannon Explorer: usecannon.com/packages/cow-omnibus
- Package name:
cow-hooks-trampoline
Verification
After deployment, verify the contract on block explorers:Troubleshooting
Build fails with “out of gas”
Increase the gas limit in your Foundry configuration:foundry.toml
Publish fails with “not authorized”
Ensure your account has permission on thecow-settlement package. Contact the CoW Protocol team to request access.
CREATE2 deployment fails
If the contract already exists at the address:- Change the salt value in
cannonfile.toml - Or use
ifExists = "continue"to skip redeployment
