Appendices
Appendix A
Complete Opcode Reference
Script is a stack-based language deliberately designed to be stateless and not Turing-complete.—Satoshi Nakamoto
This appendix catalogues every opcode recognized by Bitcoin's Script interpreter, organized by functional category. The Hex column gives the single-byte opcode value; the Dec column gives its decimal equivalent. Opcodes marked disabled will cause the script to fail immediately if encountered, even inside an unexecuted OP_IF branch. Opcodes marked reserved fail only when executed.
A.1Constants
| Hex | Dec | Name | Description |
0x00 | 0 | OP_0 / OP_FALSE | Push empty byte array (falsy) |
0x01–0x4b | 1–75 | (data push) | Push next \(N\) bytes onto stack |
0x4c | 76 | OP_PUSHDATA1 | Next byte = length; push that many bytes |
0x4d | 77 | OP_PUSHDATA2 | Next 2 bytes (LE) = length; push |
0x4e | 78 | OP_PUSHDATA4 | Next 4 bytes (LE) = length; push |
0x4f | 79 | OP_1NEGATE | Push \(-1\) |
0x50 | 80 | OP_RESERVED | Reserved; fails if executed |
0x51–0x60 | 81–96 | OP_1–OP_16 | Push value 1–16 |
A.2Flow Control
| Hex | Dec | Name | Description |
0x61 | 97 | OP_NOP | Does nothing |
0x62 | 98 | OP_VER | Reserved; fails if executed |
0x63 | 99 | OP_IF | Execute next block if top is truthy |
0x64 | 100 | OP_NOTIF | Execute next block if top is falsy |
0x65 | 101 | OP_VERIF | Disabled — always fails |
0x66 | 102 | OP_VERNOTIF | Disabled — always fails |
0x67 | 103 | OP_ELSE | Execute if preceding IF/NOTIF was false |
0x68 | 104 | OP_ENDIF | End conditional block |
0x69 | 105 | OP_VERIFY | Fail if top is falsy; otherwise pop |
0x6a | 106 | OP_RETURN | Mark output as provably unspendable |
A.3Stack Operations
| Hex | Dec | Name | Description |
0x6b | 107 | OP_TOALTSTACK | Move top item to alt stack |
0x6c | 108 | OP_FROMALTSTACK | Move top of alt stack to main stack |
0x6d | 109 | OP_2DROP | Remove top 2 items |
0x6e | 110 | OP_2DUP | Duplicate top 2 items |
0x6f | 111 | OP_3DUP | Duplicate top 3 items |
0x70 | 112 | OP_2OVER | Copy items 3–4 to top |
0x71 | 113 | OP_2ROT | Move items 5–6 to top |
0x72 | 114 | OP_2SWAP | Swap top two pairs |
0x73 | 115 | OP_IFDUP | Duplicate top if truthy |
0x74 | 116 | OP_DEPTH | Push stack depth |
0x75 | 117 | OP_DROP | Remove top item |
0x76 | 118 | OP_DUP | Duplicate top item |
0x77 | 119 | OP_NIP | Remove second item |
0x78 | 120 | OP_OVER | Copy second item to top |
0x79 | 121 | OP_PICK | Copy \(n\)th item to top |
0x7a | 122 | OP_ROLL | Move \(n\)th item to top |
0x7b | 123 | OP_ROT | Rotate top 3 items |
0x7c | 124 | OP_SWAP | Swap top 2 items |
0x7d | 125 | OP_TUCK | Copy top behind second |
A.4Splice Operations
| Hex | Dec | Name | Description |
0x7e | 126 | OP_CAT | Disabled — concatenate two strings |
0x7f | 127 | OP_SUBSTR | Disabled — return substring |
0x80 | 128 | OP_LEFT | Disabled — keep left \(n\) bytes |
0x81 | 129 | OP_RIGHT | Disabled — keep right \(n\) bytes |
0x82 | 130 | OP_SIZE | Push byte length of top item (without popping) |
A.5Bitwise Logic
| Hex | Dec | Name | Description |
0x83 | 131 | OP_INVERT | Disabled — flip all bits |
0x84 | 132 | OP_AND | Disabled — bitwise AND |
0x85 | 133 | OP_OR | Disabled — bitwise OR |
0x86 | 134 | OP_XOR | Disabled — bitwise XOR |
0x87 | 135 | OP_EQUAL | Push 1 if top two are byte-identical |
0x88 | 136 | OP_EQUALVERIFY | OP_EQUAL then OP_VERIFY |
0x89 | 137 | OP_RESERVED1 | Reserved; fails if executed |
0x8a | 138 | OP_RESERVED2 | Reserved; fails if executed |
A.6Arithmetic
All arithmetic inputs are interpreted as little-endian signed integers limited to 4 bytes (range \(-2^{31}+1\) to \(2^{31}-1\)). Results that overflow this range cause the script to fail.
| Hex | Dec | Name | Description |
0x8b | 139 | OP_1ADD | Add 1 to top |
0x8c | 140 | OP_1SUB | Subtract 1 from top |
0x8d | 141 | OP_2MUL | Disabled — multiply by 2 |
0x8e | 142 | OP_2DIV | Disabled — divide by 2 |
0x8f | 143 | OP_NEGATE | Flip sign |
0x90 | 144 | OP_ABS | Absolute value |
0x91 | 145 | OP_NOT | Push 1 if top is 0; else push 0 |
0x92 | 146 | OP_0NOTEQUAL | Push 0 if top is 0; else push 1 |
0x93 | 147 | OP_ADD | \(a + b\) |
0x94 | 148 | OP_SUB | \(a - b\) |
0x95 | 149 | OP_MUL | Disabled — \(a \times b\) |
0x96 | 150 | OP_DIV | Disabled — \(a \div b\) |
0x97 | 151 | OP_MOD | Disabled — \(a \pmod{b}\) |
0x98 | 152 | OP_LSHIFT | Disabled — left shift |
0x99 | 153 | OP_RSHIFT | Disabled — right shift |
0x9a | 154 | OP_BOOLAND | Push 1 if both non-zero |
0x9b | 155 | OP_BOOLOR | Push 1 if either non-zero |
0x9c | 156 | OP_NUMEQUAL | Push 1 if numerically equal |
0x9d | 157 | OP_NUMEQUALVERIFY | NUMEQUAL then VERIFY |
0x9e | 158 | OP_NUMNOTEQUAL | Push 1 if not equal |
0x9f | 159 | OP_LESSTHAN | Push 1 if \(a < b\) |
0xa0 | 160 | OP_GREATERTHAN | Push 1 if \(a > b\) |
0xa1 | 161 | OP_LESSTHANOREQUAL | Push 1 if \(a \le b\) |
0xa2 | 162 | OP_GREATERTHANOREQUAL | Push 1 if \(a \ge b\) |
0xa3 | 163 | OP_MIN | Push lesser of two |
0xa4 | 164 | OP_MAX | Push greater of two |
0xa5 | 165 | OP_WITHIN | Push 1 if \(\min \le x < \max\) |
A.7Cryptographic Operations
| Hex | Dec | Name | Description |
0xa6 | 166 | OP_RIPEMD160 | RIPEMD-160 hash of top item |
0xa7 | 167 | OP_SHA1 | SHA-1 hash of top item |
0xa8 | 168 | OP_SHA256 | SHA-256 hash of top item |
0xa9 | 169 | OP_HASH160 | SHA-256 then RIPEMD-160 |
0xaa | 170 | OP_HASH256 | Double SHA-256 |
0xab | 171 | OP_CODESEPARATOR | Mark script position for signature hashing |
0xac | 172 | OP_CHECKSIG | Verify ECDSA/Schnorr signature |
0xad | 173 | OP_CHECKSIGVERIFY | CHECKSIG then VERIFY |
0xae | 174 | OP_CHECKMULTISIG | Verify \(m\)-of-\(n\) ECDSA signatures |
0xaf | 175 | OP_CHECKMULTISIGVERIFY | CHECKMULTISIG then VERIFY |
A.8Locktime Operations
| Hex | Dec | Name | Description |
0xb0 | 176 | OP_NOP1 | No-op (reserved for future soft forks) |
0xb1 | 177 | OP_CHECKLOCKTIMEVERIFY | Fail unless nLockTime top (BIP 65) |
0xb2 | 178 | OP_CHECKSEQUENCEVERIFY | Fail unless relative time elapsed (BIP 112) |
0xb3–0xb9 | 179–185 | OP_NOP4–OP_NOP10 | No-ops (reserved for future soft forks) |
A.9Tapscript Extensions (BIP 342)
These opcodes redefine behavior within Tapscript execution contexts only.
| Hex | Dec | Name | Description |
0xac | 172 | OP_CHECKSIG | Schnorr signature verification (redefined) |
0xad | 173 | OP_CHECKSIGVERIFY | Schnorr verify + VERIFY (redefined) |
0xba | 186 | OP_CHECKSIGADD | Schnorr batch: increment counter if valid |
0xae | 174 | OP_CHECKMULTISIG | Disabled in Tapscript |
0xaf | 175 | OP_CHECKMULTISIGVERIFY | Disabled in Tapscript |
0xbb–0xfe | 187–254 | OP_SUCCESS187–OP_SUCCESS254 | Success opcodes (future soft forks) |
Cross-Reference
OP_CHECKSIGADD replaces the \(O(n^2)\) OP_CHECKMULTISIG for threshold signatures in Tapscript (Chapter 13, :checksigadd). The OP_SUCCESS opcodes provide upgrade hooks—any script containing an unrecognized OP_SUCCESS opcode passes unconditionally, enabling future soft-fork redefinition.