Skip to content

Instantly share code, notes, and snippets.

@bjoveski
Last active March 4, 2022 08:38
Show Gist options
  • Save bjoveski/3a2b1c1df7b2d1e58f8bf4f7b6f5904b to your computer and use it in GitHub Desktop.
Save bjoveski/3a2b1c1df7b2d1e58f8bf4f7b6f5904b to your computer and use it in GitHub Desktop.
import "./Forwarder.sol";
contract ForwarderFactory {
function initForwarder(address destination, uint256 salt) public returns (Forwarder forwarder) {
bytes memory deploymentData = abi.encodePacked(
type(Forwarder).creationCode,
uint256(destination)
);
assembly {
forwarder := create2(
0x0, add(0x20, deploymentData), mload(deploymentData), salt
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment