mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
30 lines
693 B
Solidity
30 lines
693 B
Solidity
contract D {
|
|
uint public x;
|
|
constructor(uint a) {
|
|
x = a;
|
|
}
|
|
}
|
|
|
|
contract C {
|
|
function createDSalted(bytes32 salt, uint arg) public {
|
|
address predictedAddress = address(uint160(uint(keccak256(abi.encodePacked(
|
|
bytes1(0xff),
|
|
address(this),
|
|
salt,
|
|
keccak256(abi.encodePacked(
|
|
type(D).creationCode,
|
|
arg
|
|
))
|
|
)))));
|
|
|
|
D d = new D{salt: salt}(arg);
|
|
require(address(d) == predictedAddress, "Address mismatch.");
|
|
}
|
|
}
|
|
// ====
|
|
// EVMVersion: >=constantinople
|
|
// compileViaYul: also
|
|
// ----
|
|
// createDSalted(bytes32,uint256): 42, 64 ->
|
|
// gas legacy: 104365
|