Created
May 24, 2021 05:33
-
-
Save apoorvlathey/e75deb2aeb94558798e51a5b767c548a to your computer and use it in GitHub Desktop.
Contract that allows to deploy any arbitrary contract by just passing its initcode as function argument
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
// For reference: https://twitter.com/nanexcool/status/1396667368017997829 | |
pragma solidity ^0.5.7; | |
contract DeployContract { | |
function deploy(bytes memory code) public returns(address addr) { | |
assembly { | |
addr := create(0, add(code, 0x20), mload(code)) | |
if iszero(extcodesize(addr)) { | |
revert(0,0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment