Skip to content

Instantly share code, notes, and snippets.

@mingderwang
Last active February 14, 2024 08:03
Show Gist options
  • Save mingderwang/75938c3c053161615251c10584a483b0 to your computer and use it in GitHub Desktop.
Save mingderwang/75938c3c053161615251c10584a483b0 to your computer and use it in GitHub Desktop.
// 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