Skip to content

conodits/safebox-multichain-deploy

 
 

Repository files navigation

Foundry Multichain

This repo provides an example of a multichain Solidity Deployment/Upgredability script pattern. It can also be applicable for non-upgradable contracts (remove UUPSProxy)

  • It uses CREATE2 to deploy Counter with UUPSProxy to multiple chains using a single Solidity script.

  • CREATE2 is used to preserve proxy addresses across multiple chains.

  • Likewise, it uses a single Solidity script to upgrade contracts on multiple chains.

Scripts are located at the script directory:

  • BaseDeployer.s.sol: Provides a base to the deploymeny & upgradability scripts. It includes all chains with their respective RPC urls (from foundry.toml)
  • Counter.s.sol: Counter deployment script
  • CounterUpgrade.s.sol: Counter upgreade script

Minimal set of tests are located at the tests directory.

Before running anything, make sure your .env variables are set. You can use .env-example as a template

Things you can learn & get inspiration

  • Multichain CREATE2 deploymnent
  • UUPS proxy setup and initialization
  • Multichain upgrades through UUPS proxy (preserving proxy address)
  • Upgradability tests

Running Tests

To build & run tests, run the following command

  forge test -vvvv 

Examples

Deploy to testnets

  • deployCounterTestnet(uint256 _counterSalt, uint256 _counterProxySalt)
forge script DeployCounter -s "deployCounterTestnet(uint256, uint256)" 5 6 --force --multi 
  • add --broadcast --verify to broadcast to network and verify contracts

Deploy to selected chains

  • deployCounterSelectedChains(uint256 _counterSalt, uint256 _counterProxySalt, Chains[] calldata deployForks, Cycle cycle)
forge script DeployCounter -s "deployCounterSelectedChains(uint256, uint256, uint8[] calldata, uint8)" 154 155 "[3,4,5,6]" 1 --force --multi 
  • add --broadcast --verify to broadcast to network and verify contracts

Upgrade on testnets

  • upgradeTestnet()
forge script UpgradeCounter -s "upgradeTestnet()" --force --multi
  • add --broadcast --verify to broadcast to network and verify contracts

Upgrade on selected chains

  • upgradeSelectedChains(Chains[] calldata upgradeForks, Cycle cycle)
forge script UpgradeCounter -s "upgradeSelectedChains(uint8[] calldata, uint8)" "[3]" 1 --force --multi 
  • add --broadcast --verify to broadcast to network and verify contracts

Acknowledgements

License

MIT

About

Foundry multichain chain solidity deployment script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 99.2%
  • Shell 0.8%