Skip to content

Instantly share code, notes, and snippets.

@seaona
Created August 9, 2023 09:11
Show Gist options
  • Save seaona/f54eb150860ba81f2d8e59a3a354ea38 to your computer and use it in GitHub Desktop.
Save seaona/f54eb150860ba81f2d8e59a3a354ea38 to your computer and use it in GitHub Desktop.
Create3 Solidity
pragma solidity 0.8.18;
import "https://github.com/0xsequence/create3/contracts/Create3.sol";
contract Child {
uint8 public a;
function hola() public {
a = 5;
}
}
contract Deployer {
address public addr;
event isCon(bool con);
function deployChild() external {
addr = Create3.create3(
keccak256(bytes("<my salt>")),
type(Child).creationCode
);
}
function isContract(address _addr) public {
uint32 size;
assembly {
size := extcodesize(_addr)
}
emit isCon(size > 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment