Last active
January 29, 2024 03:24
-
-
Save ashwinYardi/4b711288a1332ed71596419f6a7fbd72 to your computer and use it in GitHub Desktop.
EIP-1167 clone method
This file contains 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
function clone(address implementation) internal returns (address instance) { | |
assembly { | |
let ptr := mload(0x40) | |
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) | |
mstore(add(ptr, 0x14), shl(0x60, implementation)) | |
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) | |
instance := create(0, ptr, 0x37) | |
} | |
require(instance != address(0), "ERC1167: create failed"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment