How to deploy a smart contract on multiple networks and keeping the contract address same in all the networks? #5300
-
How to deploy a smart contract on multiple networks and keeping the contract address same in all the networks? Please help me with this situation, if is there any way to do such . |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @debo024! The address of an Ethereum contract is deterministically computed, from the It is possible but not super straightforward to make the contract addresses the same in every deployment. I found this article helpful as far as workarounds to ensure that the contract address is the same in every network (be sure to read to the end for some sample scripts!): https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed Your sender address will be the same in every EVM network (i.e. your seed phrase will deterministically lead to the same addresses), but the nonce part may or may not be the same depending on whether a transaction has already occurred at the contract address you seek to use. EDIT: The way to do this may be through CREATE2. There is some discussion of it in the Stack Overflow link I shared, but there is also some good documentation on it here: https://docs.openzeppelin.com/cli/2.8/deploying-with-create2 If you use the same sender address you may be able to guarantee the same contract address on all EVM networks through CREATE2. @haltman-at knows a ton about this so I am tagging him in case I got anything wrong here! I hope this response was helpful! |
Beta Was this translation helpful? Give feedback.
Hi @debo024! The address of an Ethereum contract is deterministically computed, from the
sender
and thenonce
. I assume we are talking about Ethereum-compatible networks here.It is possible but not super straightforward to make the contract addresses the same in every deployment. I found this article helpful as far as workarounds to ensure that the contract address is the same in every network (be sure to read to the end for some sample scripts!): https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
Your sender address will be the same in every EVM network (i.e. your seed phrase will deterministically lead to the same addresses), but the no…