-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deployer.sol
33 lines (26 loc) · 1.01 KB
/
Deployer.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Deployer {
event Deploy(address indexed deployAddr, address indexed solver, uint indexed problemNum);
receive() external payable {}
// bytecode should be abi.encodePacked(creationCode, constructorCode);
function deploy(bytes memory bytecode, address solver, uint problemNum)
external
payable
returns (address addr) {
bytes32 _salt = keccak256(abi.encodePacked(block.timestamp, msg.sender));
assembly {
addr := create2(
callvalue(), // wei sent with current call
// Actual code starts after skipping the first 32 bytes
add(bytecode, 0x20),
mload(bytecode), // Load the size of code contained in the first 32 bytes
_salt // Salt from function arguments
)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
emit Deploy(addr, solver, problemNum);
}
}