wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

Constant address deployment for multi-chain contracts #409

Closed defikintaro closed 1 year ago

defikintaro commented 1 year ago

Hello !

Deployment of the contracts between the different chains can be sometimes a bit cumbersome. The contract addresses depend on deployer address and his nonce. And when this nonce is the same on the different chains you'll get the same addresses for the deployed contracts. Normally by using this a token contract can have the same address in the different chains thus this will enable consistency and lesser doc entries.

I am thinking about it would be great to add this support in the tool to allow multi-chain developers have a consistent set-up for the new contracts. Also I've seen this application in Axelar's example contract linker deployments for linking the token contracts with bridges. They're initially deploying a ConstAddressDeployer contract whenever a fresh wallet connects to a network, then deploy linker contracts with that deployer contract. https://github.com/axelarnetwork/axelar-local-gmp-examples

cheers !

wighawag commented 1 year ago

hardhat-deploy support this feature with the deterministicDeployment option of the deploy function

You can also configure factories via : https://github.com/wighawag/hardhat-deploy#4-deterministicdeployment-ability-to-specify-a-deployment-factory