pragma solidity ^0.4.22;
contract HelloWorld {
function() public {
log0(bytes32("Hello world!"));
}
}
solc ./HelloWorld.sol --bin-runtime
HelloWorld.sol
6080604052348015600f
57600080fd5b50604051
80807f48656c6c6f2077
6f726c64210000000000
00000000000000000000
0000000000815250600c
01905060405180910390
a00000a165627a7a7230
5820860d44530a302ca6
28b1e865093d54f53da6
be5e6650b84b5440b574
6222d7b60029
10 50 +
ARG ARG OP
10 50 +
10
50
60
0x01: ADD
0x02: MUL
0x03: SUB
0x04: DIV
0x05: SDIV
0x06: MOD
0x07: SMOD
0x08: ADDMOD
0x09: MULMOD
0x0a: EXP
0x0b: SIGNEXTEND
0x10: LT
0x11: GT
0x12: SLT
0x13: SGT
0x14: EQ
0x15: ISZERO
0x16: AND
0x17: OR
0x18: XOR
0x19: NOT
0x1a: BYTE
0x30: ADDRESS
0x31: BALANCE
0x32: ORIGIN
0x33: CALLER
0x34: CALLVALUE
0x35: CALLDATALOAD
0x36: CALLDATASIZE
0x37: CALLDATACOPY
0x38: CODESIZE
0x39: CODECOPY
0x3a: GASPRICE
0x3b: EXTCODESIZE
0x3c: EXTCODECOPY
0x20: SHA3
0x40: BLOCKHASH
0x41: COINBASE
0x42: TIMESTAMP
0x43: NUMBER
0x44: DIFFICULTY
0x45: GASLIMIT
0x50: POP
0x51: MLOAD
0x52: MSTORE
0x53: MSTORE8
0x54: SLOAD
0x55: SSTORE
0x56: JUMP
0x57: JUMPI
0x58: PC
0x59: MSIZE
0x5a: GAS
0x5b: JUMPDEST
0x60: PUSH1
...
0x7f: PUSH32
0x80: DUP1
...
0x8f: DUP16
0xf0: CREATE
0xf1: CALL
0xf2: CALLCODE
0xf3: RETURN
0xf4: DELEGATECALL
0xff: SELFDESTRUCT
0x90: SWAP1
...
0x9f: SWAP16
0xa0: LOG0
0xa1: LOG1
0xa2: LOG2
0xa3: LOG3
0xa4: LOG4
But how?
(365 days)
603C
603C
02
6018
02
61016D
02
Formula:
{
0x05 // You can use hex
15 // But also dec
add // Call op-codes by name
// Need to have an empty
// stack at the end
pop
}
{
// Compute seconds in a day
60
60
mul
24
mul
// Push 365 to the stack
365
mul
// Need balanced stack at the end
pop
}
{
mul(60, 60)
}
Jump If Not Zero
6020 6000 6000 37
6020 6020 6020 37
6000 51
6020 51
11
601d
57
6020 6000 f3
5b
6020 6020 f3
{
jump(label) // Use function-syntax
// This is how you define a label
label:
selfdestruct(0x0)
}
{
calldatacopy(0, 0, 32)
calldatacopy(32, 32, 32)
mload(0)
mload(32)
gt
greater_than
jumpi
return(0, 32)
greater_than:
return(32, 32)
}
Arguments:
Identical to CALL but does not allow state modifications
call(
0x48,
0x000000000000000000000000000000000000002,
0x00,
0x00,
0x20,
0x21,
0x20
)
Property | Type | Description |
---|---|---|
From | Address | Sender |
To | Address | Receiver |
Data | Hex | Code to execute |
Gas | Wei | Execution cost |
Value | Wei | Value to transfer |
Property | Type | Value |
---|---|---|
From | Address | Your account |
To | Address | 0x0 |
Data | Hex | Deploy code |
Gas | Wei | Depends on code |
Value | Wei | Depends |
dec(0x23): 35
dec(0x0b): 11
Contract code
Code size: 35
35
35
11
00
00
CODECOPY(00, 11, 35)
CODECOPY(MEM, FROM, TO)
RETURN(00, 35)
RETURN(FROM, TO)
0xcdcd77c0
0000000000000000
0000000000000000
0000000000000000
0000000000000045
0000000000000000
0000000000000000
0000000000000000
0000000000000001
{
let mem_start_first := 0
let mem_start_second := 32
calldatacopy(0, mem_start_first, 32)
calldatacopy(32, mem_start_second, 32)
let first := mload(mem_start_first)
let second := mload(mem_start_second)
if gt(first, second) {
return(mem_start_first, 32)
}
return(mem_start_second, 32)
}
00 PUSH1 => 00
02 PUSH1 => 20
04 PUSH1 => 20
06 DUP3
07 PUSH1 => 00
09 CALLDATACOPY
10 PUSH1 => 20
12 DUP2
13 PUSH1 => 20
15 CALLDATACOPY
16 DUP2
17 MLOAD
18 DUP2
19 MLOAD
20 DUP1
21 DUP3
22 GT
23 ISZERO
24 PUSH1 => 1f
26 JUMPI
27 PUSH1 => 20
29 DUP5
30 RETURN
31 JUMPDEST
32 PUSH1 => 20
34 DUP4
35 RETURN
36 POP
37 POP
38 POP
39 POP
00: PUSH1 0x20
02: PUSH1 0x00
04: PUSH1 0x00
06: CALLDATACOPY
07: PUSH1 0x20
09: PUSH1 0x20
11: PUSH1 0x20
13: CALLDATACOPY
14: PUSH1 0x00
16: MLOAD
17: PUSH1 0x20
19: MLOAD
20: GT
21: PUSH1 0x1d
23: JUMPI
24: PUSH1 0x20
26: PUSH1 0x00
28: RETURN
29: JUMPDEST
30: PUSH1 0x20
32: PUSH1 0x20
34: RETURN
{
for { let i := 0 }
lt(i, 2)
{ i := add(i, 1) } {
mstore(0, i)
log0(0, 32)
}
}
00 PUSH1 => 00
02 JUMPDEST
03 PUSH1 => 02
05 DUP2
06 LT
07 ISZERO
08 PUSH1 => 1e
10 JUMPI
11 DUP1
12 PUSH1 => 00
14 MSTORE
15 PUSH1 => 20
17 PUSH1 => 00
19 LOG0
20 JUMPDEST
21 PUSH1 => 01
23 DUP2
24 ADD
25 SWAP1
26 POP
27 PUSH1 => 02
29 JUMP
30 JUMPDEST
31 POP
{
function even(value) -> result {
let remainer := mod(value, 2)
result := iszero(remainer)
}
}
00 PUSH1 => 13
02 JUMP
03 JUMPDEST
04 PUSH1 => 00
06 PUSH1 => 02
08 DUP3
09 MOD
10 DUP1
11 ISZERO
12 SWAP2
13 POP
14 POP
15 SWAP2
16 SWAP1
17 POP
18 JUMP
19 JUMPDEST
pragma solidity ^0.4.22;
contract HelloWorld {
function() public {
log0(bytes32("Hello world!"));
}
}
6080604052348015600f
57600080fd5b50604051
80807f48656c6c6f2077
6f726c64210000000000
00000000000000000000
0000000000815250600c
01905060405180910390
a00000a165627a7a7230
5820860d44530a302ca6
28b1e865093d54f53da6
be5e6650b84b5440b574
6222d7b60029
7f48656c6c6f20776f72
6c642100000000000000
00000000000000000000
00000060005260206000
a0
https://tenx.tech
https://coblox.tech