Files
proxmox/thirdweb-core-2103-test/src/Create2Factory.sol

25 lines
904 B
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/utils/Create2.sol";
import { Create2Probe } from "./Create2Probe.sol";
/// @dev Thin factory so CREATE2 runs inside contract code (same pattern as production deployers).
contract Create2Factory {
event ProbeDeployed(address indexed probe, bytes32 salt);
function probeInitCodeHash() external pure returns (bytes32) {
return keccak256(type(Create2Probe).creationCode);
}
function predictProbe(bytes32 salt) external view returns (address) {
return Create2.computeAddress(salt, keccak256(type(Create2Probe).creationCode), address(this));
}
function deployProbe(bytes32 salt) external returns (address addr) {
bytes memory bytecode = type(Create2Probe).creationCode;
addr = Create2.deploy(0, salt, bytecode);
emit ProbeDeployed(addr, salt);
}
}