メインコンテンツへスキップ
Change page

EVMのオペコード

最終編集者: @HiroyukiNaito(opens in a new tab), 2024年7月3日

概要

wolflo/evm-opcodes(opens in a new tab)で公開されているEVMリファレンスページの最新版です。 Yellow Paper(opens in a new tab)Jello Paper(opens in a new tab)geth(opens in a new tab)の実装からも引用されています。 わかりやすいリファレンスを目指していますが、とりわけ厳密なものではありません。 すべてのエッジケースを正確に把握したい場合は、Jello Paperまたはクライアント実装をご利用ください。

インタラクティブなリファレンスも用意されているので、 evm.codes(opens in a new tab)をご覧ください。

ダイナミックなガス代の演算については、gas.md(opens in a new tab)を参照してください。

💡 ヒント: 行全体を表示するには、 [shift] + スクロールを使用してデスクトップ上で水平方向にスクロールします。

スタック名前ガス初期スタック結果スタックMem/ストレージ注記
00STOP0halt execution
01ADD3a, ba + b(u)int256 addition modulo 2**256
02MUL5a, ba * b(u)int256 multiplication modulo 2**256
03SUB3a, ba - b(u)int256 addition modulo 2**256
04DIV5a, ba // buint256 division
05SDIV5a, ba // bint256 division
06MOD5a, ba % buint256 modulus
07SMOD5a, ba % bint256 modulus
08ADDMOD8a, b, N(a + b) % N(u)int256 addition modulo N
09MULMOD8a, b, N(a * b) % N(u)int256 multiplication modulo N
0AEXPA1(opens in a new tab)a, ba ** buint256 exponentiation modulo 2**256
0BSIGNEXTEND5b, xSIGNEXTEND(x, b)sign extend(opens in a new tab) x from (b+1) bytes to 32 bytes
0C-0Finvalid
10LT3a, ba < buint256 less-than
11GT3a, ba > buint256 greater-than
12SLT3a, ba < bint256 less-than
13SGT3a, ba > bint256 greater-than
14EQ3a, ba == b(u)int256 equality
15ISZERO3aa == 0(u)int256 iszero
16AND3a, ba && bbitwise AND
17OR3a, ba \|\| bbitwise OR
18XOR3a, ba ^ bbitwise XOR
19NOT3a~abitwise NOT
1ABYTE3i, x(x >> (248 - i * 8)) && 0xFFith byte of (u)int256 x, from the left
1BSHL3shift, valval << shiftshift left
1CSHR3shift, valval >> shiftlogical shift right
1DSAR3shift, valval >> shiftarithmetic shift right
1E-1Finvalid
20KECCAK256A2(opens in a new tab)ost, lenkeccak256(mem[ost:ost+len-1])keccak256
21-2Finvalid
30ADDRESS2address(this)address of executing contract
31BALANCEA5(opens in a new tab)addraddr.balancebalance, in wei
32ORIGIN2tx.originaddress that originated the tx
33CALLER2msg.senderaddress of msg sender
34CALLVALUE2msg.valuemsg value, in wei
35CALLDATALOAD3idxmsg.data[idx:idx+32]read word from msg data at index idx
36CALLDATASIZE2len(msg.data)length of msg data, in bytes
37CALLDATACOPYA3(opens in a new tab)dstOst, ost, lenmem[dstOst:dstOst+len-1] := msg.data[ost:ost+len-1]copy msg data
38CODESIZE2len(this.code)length of executing contract's code, in bytes
39CODECOPYA3(opens in a new tab)dstOst, ost, lenmem[dstOst:dstOst+len-1] := this.code[ost:ost+len-1]
3AGASPRICE2tx.gaspricegas price of tx, in wei per unit gas **(opens in a new tab)
3BEXTCODESIZEA5(opens in a new tab)addrlen(addr.code)size of code at addr, in bytes
3CEXTCODECOPYA4(opens in a new tab)addr, dstOst, ost, lenmem[dstOst:dstOst+len-1] := addr.code[ost:ost+len-1]copy code from addr
3DRETURNDATASIZE2sizesize of returned data from last external call, in bytes
3ERETURNDATACOPYA3(opens in a new tab)dstOst, ost, lenmem[dstOst:dstOst+len-1] := returndata[ost:ost+len-1]copy returned data from last external call
3FEXTCODEHASHA5(opens in a new tab)addrハッシュhash = addr.exists ? keccak256(addr.code) : 0
40BLOCKHASH20blockNumblockHash(blockNum)
41COINBASE2block.coinbase現在のブロックの提案者アドレス
42TIMESTAMP2block.timestamptimestamp of current block
43NUMBER2block.numbernumber of current block
44PREVRANDAO2randomness beaconrandomness beacon
45GASLIMIT2block.gaslimitgas limit of current block
46CHAINID2chain_idpush current chain id(opens in a new tab) onto stack
47SELFBALANCE5address(this).balancebalance of executing contract, in wei
48BASEFEE2block.basefeebase fee of current block
49BLOBHASH3idxtx.blob_versioned_hashes[idx]EIP-4844(opens in a new tab)
4ABLOBBASEFEE2block.blobbasefee現在のブロックのブロブベースフィー(EIP-7516(opens in a new tab))
4B-4Finvalid
50POP2_anonremove item from top of stack and discard it
51MLOAD3*(opens in a new tab)ostmem[ost:ost+32]read word from memory at offset ost
52MSTORE3*(opens in a new tab)ost, valmem[ost:ost+32] := valwrite a word to memory
53MSTORE83*(opens in a new tab)ost, valmem[ost] := val && 0xFFwrite a single byte to memory
54SLOADA6(opens in a new tab)keystorage[key]read word from storage
55SSTOREA7(opens in a new tab)key, valstorage[key] := valwrite word to storage
56JUMP8dst$pc := dst mark that pc is only assigned if dst is a valid jumpdest
57JUMPI10dst, condition$pc := condition ? dst : $pc + 1
58PC2$pcprogram counter
59MSIZE2len(mem)size of memory in current execution context, in bytes
5AGAS2gasRemaining
5BJUMPDEST1mark valid jump destinationa valid jump destination for example a jump destination not inside the push data
5CTLOAD100keytstorage[key]一時ストレージからワードを読み込む(EIP-1153(opens in a new tab))
5DTSTORE100key, valtstorage[key] := val一時ストレージへワードを書き込む (EIP-1153(opens in a new tab))
5EMCOPY3+3*words+A0(opens in a new tab)dstOst, ost, lenmem[dstOst] := mem[ost:ost+len]メモリをあるエリアから別のエリアへコピーする(EIP-5656(opens in a new tab))
5EPUSH02uint8スタックへ定数値0をプッシュ
60PUSH13uint8push 1-byte value onto stack
61PUSH23uint16push 2-byte value onto stack
62PUSH33uint24push 3-byte value onto stack
63PUSH43uint32push 4-byte value onto stack
64PUSH53uint40push 5-byte value onto stack
65PUSH63uint48push 6-byte value onto stack
66PUSH73uint56push 7-byte value onto stack
67PUSH83uint64push 8-byte value onto stack
68PUSH93uint72push 9-byte value onto stack
69PUSH103uint80push 10-byte value onto stack
6APUSH113uint88push 11-byte value onto stack
6BPUSH123uint96push 12-byte value onto stack
6CPUSH133uint104push 13-byte value onto stack
6DPUSH143uint112push 14-byte value onto stack
6EPUSH153uint120push 15-byte value onto stack
6FPUSH163uint128push 16-byte value onto stack
70PUSH173uint136push 17-byte value onto stack
71PUSH183uint144push 18-byte value onto stack
72PUSH193uint152push 19-byte value onto stack
73PUSH203uint160push 20-byte value onto stack
74PUSH213uint168push 21-byte value onto stack
75PUSH223uint176push 22-byte value onto stack
76PUSH233uint184push 23-byte value onto stack
77PUSH243uint192push 24-byte value onto stack
78PUSH253uint200push 25-byte value onto stack
79PUSH263uint208push 26-byte value onto stack
7APUSH273uint216push 27-byte value onto stack
7BPUSH283uint224push 28-byte value onto stack
7CPUSH293uint232push 29-byte value onto stack
7DPUSH303uint240push 30-byte value onto stack
7EPUSH313uint248push 31-byte value onto stack
7FPUSH323uint256push 32-byte value onto stack
80DUP13aa, aclone 1st value on stack
81DUP23_, aa, _, aclone 2nd value on stack
82DUP33_, _, aa, _, _, aclone 3rd value on stack
83DUP43_, _, _, aa, _, _, _, aclone 4th value on stack
84DUP53..., aa, ..., aclone 5th value on stack
85DUP63..., aa, ..., aclone 6th value on stack
86DUP73..., aa, ..., aclone 7th value on stack
87DUP83..., aa, ..., aclone 8th value on stack
88DUP93..., aa, ..., aclone 9th value on stack
89DUP103..., aa, ..., aclone 10th value on stack
8ADUP113..., aa, ..., aclone 11th value on stack
8BDUP123..., aa, ..., aclone 12th value on stack
8CDUP133..., aa, ..., aclone 13th value on stack
8DDUP143..., aa, ..., aclone 14th value on stack
8EDUP153..., aa, ..., aclone 15th value on stack
8FDUP163..., aa, ..., aclone 16th value on stack
90SWAP13a, bb, a
91SWAP23a, _, bb, _, a
92SWAP33a, _, _, bb, _, _, a
93SWAP43a, _, _, _, bb, _, _, _, a
94SWAP53a, ..., bb, ..., a
95SWAP63a, ..., bb, ..., a
96SWAP73a, ..., bb, ..., a
97SWAP83a, ..., bb, ..., a
98SWAP93a, ..., bb, ..., a
99SWAP103a, ..., bb, ..., a
9ASWAP113a, ..., bb, ..., a
9BSWAP123a, ..., bb, ..., a
9CSWAP133a, ..., bb, ..., a
9DSWAP143a, ..., bb, ..., a
9ESWAP153a, ..., bb, ..., a
9FSWAP163a, ..., bb, ..., a
A0LOG0A8(opens in a new tab)ost, lenLOG0(memory[ost:ost+len-1])
A1LOG1A8(opens in a new tab)ost, len, topic0LOG1(memory[ost:ost+len-1], topic0)
A2LOG2A8(opens in a new tab)ost, len, topic0, topic1LOG2(memory[ost:ost+len-1], topic0, topic1)
A3LOG3A8(opens in a new tab)ost, len, topic0, topic1, topic2LOG3(memory[ost:ost+len-1], topic0, topic1, topic2)
A4LOG4A8(opens in a new tab)ost, len, topic0, topic1, topic2, topic3LOG4(memory[ost:ost+len-1], topic0, topic1, topic2, topic3)
A5-EFinvalid
F0CREATEA9(opens in a new tab)val, ost, lenaddraddr = keccak256(rlp([address(this), this.nonce]))
F1CALLAA(opens in a new tab)gas, addr, val, argOst, argLen, retOst, retLensuccessmem[retOst:retOst+retLen-1] := returndata
F2CALLCODEAA(opens in a new tab)gas, addr, val, argOst, argLen, retOst, retLensuccessmem[retOst:retOst+retLen-1] = returndatasame as DELEGATECALL, but does not propagate original msg.sender and msg.value
F3RETURN0*(opens in a new tab)ost, lenreturn mem[ost:ost+len-1]
F4DELEGATECALLAA(opens in a new tab)gas, addr, argOst, argLen, retOst, retLensuccessmem[retOst:retOst+retLen-1] := returndata
F5CREATE2A9(opens in a new tab)val, ost, len, saltaddraddr = keccak256(0xff ++ address(this) ++ salt ++ keccak256(mem[ost:ost+len-1]))[12:]
F6-F9invalid
FASTATICCALLAA(opens in a new tab)gas, addr, argOst, argLen, retOst, retLensuccessmem[retOst:retOst+retLen-1] := returndata
FB-FCinvalid
FDREVERT0*(opens in a new tab)ost, lenrevert(mem[ost:ost+len-1])
FEINVALIDAF(opens in a new tab)designated invalid opcode - EIP-141(opens in a new tab)
FFSELFDESTRUCTAB(opens in a new tab)addrすべてのETHをaddrへ送信する。コントラクトが作成されたのと同じトランザクションで実行された場合、コントラクトは破壊されます。

この記事は役に立ちましたか?