0

How can I redeploy a different smart contract on the same address after selfdestruct()?

I know that with CREATE2 I can place a smart contract on a specific address. But after I remove the source code from that address through selfdestruct() how can I redeploy a different smart contract on that same address?

1 Answer 1

2

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

1
  • But so when you see a contract that was "Reinit" on Etherscan, does it mean it has the same bytecode, or do people brute-force their way into finding a salt that gives the same address for a given new bytecode?
    – Mouradif
    Commented Feb 9 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.