If the contract was deployed using CREATE
opcode (the normal contract deployment), then it's impossible. Because the address is calculated based on the deployer's nonce new_address
is derived from keccak256(sender, nonce)
. And your deployer nonce is always increasing.
If the contract was deployed using CREATE2
opcode in EIP-1014 then YES, it's possible because the contract address is deterministic: new_address
is derived from keccak256(0xFF, sender, salt, bytecode)
. You can take a look at how to use CREATE2
in very details from openzeppelin
About CREATE2, although the address is computed using hash of the bytecode, there was an interesting method to deploy arbitrary bytecode on the same address with this Metamorphosis Smart Contracts pattern