Skip to content

Instantly share code, notes, and snippets.

View tpmccallum's full-sized avatar

Timothy McCallum tpmccallum

View GitHub Profile

Pretty printed source

object "SimpleStorage_22" {
    code {
        {
            mstore(64, 128)
            let _1 := datasize("SimpleStorage_22_deployed")
            codecopy(0, dataoffset("SimpleStorage_22_deployed"), _1)
            return(0, _1)
        }

Text representation

    /* "/Users/tpmccallum/simple_storage/simple_storage_yul_ir.txt":58:61   */
  0x80
    /* "/Users/tpmccallum/simple_storage/simple_storage_yul_ir.txt":54:56   */
  0x40
    /* "/Users/tpmccallum/simple_storage/simple_storage_yul_ir.txt":47:62   */
  mstore
  dataSize(sub_0)
    /* "/Users/tpmccallum/simple_storage/simple_storage_yul_ir.txt":292:329   */

Binary representation

608060405260d280610014600039806000f350fe6080604052600436101515608a5760008035
60e01c6360fe47b18114602c57636d4ce63c81146057576087565b34156035578182fd5b6020
600319360112156045578182fd5b60043582558160528360a4565bf36087565b341560605781
82fd5b8160031936011215606f578182fd5b815460788360a4565b80608183836093565b0381
f350505b50505b60006000fd60d1565b600060208201905082825292915050565b6000604051
905081810181811067ffffffffffffffff8211171560c75760006000fd5b8060405250919050
565b

Pretty printed source

object "SimpleStorage_22" {
    code {
        {
            mstore(64, 128)
            let _1 := datasize("SimpleStorage_22_deployed")
            codecopy(0, dataoffset("SimpleStorage_22_deployed"), _1)
            return(0, _1)
        }

Command

solc/solc --strict-assembly --optimize ~/simple_storage/simple_storage_yul_ir.txt 

Command

tpmccallum$ solc/solc --ir ~/simple_storage/simple_storage.sol

Output

object "SimpleStorage_22" {
    code {
        mstore(64, 128)
function mstore(x1, x2, x3, x4, y1, y2, y3, y4) {
    let pos := u256_to_i32ptr(x1, x2, x3, x4)
    i64.store(pos, endian_swap(x1))
    i64.store(i64.add(pos, 8), endian_swap(x2))
    i64.store(i64.add(pos, 16), endian_swap(x3))
    i64.store(i64.add(pos, 24), endian_swap(x4))
}

Python

selectorHash = "0x" + str(web3.toHex(web3.sha3(text="set(uint256)")))[2:10]

Javascript

var selectorHash = web3.sha3("set(uint256)").substring(0,10)
selectorHash = "0x" + str(web3.toHex(web3.sha3(text="set(uint256)")))[2:10]
web3.sha3("set(uint256)").substring(0,10)