Created
December 20, 2018 08:25
-
-
Save chriseth/f55c0384f6bb11e3970830a160ca5c03 to your computer and use it in GitHub Desktop.
Example YUL contract
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
// Compile the following using ``solc --strict-assembly example.yul`` | |
object "MyContract" { | |
code { | |
// this is the constructor. | |
// store the creator in the first storage slot | |
sstore(0, caller()) | |
// now return the runtime code using the special functions | |
datacopy(0, dataoffset("Runtime"), datasize("Runtime")) | |
return(0, datasize("Runtime")) | |
} | |
object "Runtime" { | |
code { | |
// runtime - just return the creator | |
mstore(0, sload(0)) | |
return(0, 0x20) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment