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
.0xC1
address is derived fromnonce=1
andaddress=0xC2
, right?I call self destruct on
0xC2
(TempCreator).I redeploy TempCreator at
0xC2
using 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
SC1
at address0xD1
.SC1
deploysSC2
usingCREATE2
to address0xC2
.0xC2 ≈ 0xD1 + bytecode + salt
SC2
deploysSC3
, usingCREATE
to address0xC1
.0xC1 ≈ nonce:1 + 0xC2
SC2
calls self destruct.SC1
re-deploysSC2-new
usingCREATE2
(to the same address:0xC2
).the nonce for
SC2-new
is reset to 1, correct?SC2-new
deploysSC4
usingCREATE
.
What happens next?!? Does SC4
overwrite SC3
at address 0xC1
?