Deployed: https://rinkeby.etherscan.io/address/0x121e370ae349425d0d744f6db43c2f43e777f972#code
pragma solidity 0.8.3;
contract Test {
uint256 public a;
constructor (uint256 _a) public {
a = _a;
}
}
contract DeployTest {
function deploy(bytes32 _salt, uint256 param) public {
new Test{salt: _salt}(param);
}
}
Transaction 1
- Salt:
0x7465737400000000000000000000000000000000000000000000000000000000 - Param: 1
- TX: https://rinkeby.etherscan.io/tx/0x7a7a6db558dd049f2318b72719ec8f9c9ad918ef153b18af5dcfc7547301e5c5#internal
- Deployed: https://rinkeby.etherscan.io/address/0x8a3c2609403d812de94179a7fffe182ea5efe97d#readContract
Transaction 2
- Salt:
0x7465737400000000000000000000000000000000000000000000000000000000(same) - Param: 2
- TX: https://rinkeby.etherscan.io/tx/0x951ad8b244b2d02ff6ff79125547dabafa0f6a97a1019f7d36765f1d17ad9ace#internal
- Deployed: https://rinkeby.etherscan.io/address/0xe1127decf6f9ad9b414540238490bc53badb0f00#readContract
I was expecting that the new deployment will override the old one?
I was looking at this article: https://hackernoon.com/using-ethereums-create2-nw2137q7
In Solidity assembly, create2() takes 4 parameters: 1: The amount of wei to send to the new contract as msg.value. This is 0 for this example. 2–3: The location of the bytecode in memory 4: The salt — that we will calculate in step 3. We leave this as a parameter so it can we provided after we have calculated it.
I'm not using assembly. I'm using Solidity code and constructor parameters.
I will do some more experiments but maybe you'll know - can I override the existing contract if I use the same salt but different constructor parameters?