Skip to content

Instantly share code, notes, and snippets.

@chriseth
Created December 20, 2018 08:25
Show Gist options
  • Save chriseth/f55c0384f6bb11e3970830a160ca5c03 to your computer and use it in GitHub Desktop.
Save chriseth/f55c0384f6bb11e3970830a160ca5c03 to your computer and use it in GitHub Desktop.
Example YUL contract
// 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