Last active
February 14, 2024 08:03
-
-
Save mingderwang/75938c3c053161615251c10584a483b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.9; | |
contract DeterministicDeployFactory { | |
event Deploy(address addr); | |
function deploy(bytes memory bytecode, uint _salt) external { | |
address addr; | |
assembly { | |
addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) | |
if iszero(extcodesize(addr)) { | |
revert(0, 0) | |
} | |
} | |
emit Deploy(addr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment