Let's say I am using a (Gnosis) Safe as my main deployer account (0xD1) to allow for use of CREATE2 calls.
I use my main account,
0xD1, to deploy a "TempCreator" contract (0xC2) usingCREATE2.I use the TempCreator,
0xC2, to deploy the "Target" contract (0xC1) usingCREATE.0xC1address is derived fromnonce=1andaddress=0xC2, right?I call self destruct on
0xC2(TempCreator).I redeploy TempCreator at
0xC2using CREATE2.
Question: What happens if I deploy a new contract from TempCreator using CREATE?
- Will it overwrite the existing code at the same address of the existing Target contract,
0xC1? - What if the newly deployed byte code isn't the same size, does anything remain (possible overflow code execution)?
Explained again:
Start with
SC1at address0xD1.SC1deploysSC2usingCREATE2to address0xC2.0xC2 ≈ 0xD1 + bytecode + saltSC2deploysSC3, usingCREATEto address0xC1.0xC1 ≈ nonce:1 + 0xC2SC2calls self destruct.SC1re-deploysSC2-newusingCREATE2(to the same address:0xC2).the nonce for
SC2-newis reset to 1, correct?SC2-newdeploysSC4usingCREATE.
What happens next?!? Does SC4 overwrite SC3 at address 0xC1?
SC3/0xC1first? Would I then be able to deploy new code to the same address, given this pattern? – L Co Nov 28 '23 at 17:14