Expand description
Bitcoin Script opcode constant definitions. Bitcoin script opcode definitions.
All standard opcodes from OP_0 (0x00) through OP_INVALIDOPCODE (0xff). Includes opcode-to-string and string-to-opcode mappings for ASM output, plus utility functions for classifying opcodes.
Constants§
- OP_0
- Push an empty byte array (false/zero) onto the stack.
- OP_
0NOTEQUAL - Push 0 if the top item is 0, push 1 otherwise.
- OP_1
- Push the number 1 onto the stack.
- OP_2
- Push the number 2 onto the stack.
- OP_3
- Push the number 3 onto the stack.
- OP_4
- Push the number 4 onto the stack.
- OP_5
- Push the number 5 onto the stack.
- OP_6
- Push the number 6 onto the stack.
- OP_7
- Push the number 7 onto the stack.
- OP_8
- Push the number 8 onto the stack.
- OP_9
- Push the number 9 onto the stack.
- OP_1ADD
- Add 1 to the top stack item.
- OP_
1NEGATE - Push the number -1 onto the stack.
- OP_1SUB
- Subtract 1 from the top stack item.
- OP_2DIV
- Divide the top stack item by 2 (disabled).
- OP_
2DROP - Remove the top two stack items.
- OP_2DUP
- Duplicate the top two stack items.
- OP_2MUL
- Multiply the top stack item by 2 (disabled).
- OP_
2OVER - Copy the pair of items two spaces back to the front of the stack.
- OP_2ROT
- Move the fifth and sixth items to the top of the stack.
- OP_
2SWAP - Swap the top two pairs of items on the stack.
- OP_3DUP
- Duplicate the top three stack items.
- OP_10
- Push the number 10 onto the stack.
- OP_11
- Push the number 11 onto the stack.
- OP_12
- Push the number 12 onto the stack.
- OP_13
- Push the number 13 onto the stack.
- OP_14
- Push the number 14 onto the stack.
- OP_15
- Push the number 15 onto the stack.
- OP_16
- Push the number 16 onto the stack.
- OP_ABS
- Replace the top stack item with its absolute value.
- OP_ADD
- Pop two items, push their sum.
- OP_AND
- Bitwise AND of the top two stack items.
- OP_BASE
- Base value for small integer opcodes (OP_1 through OP_16 = OP_BASE + N).
- OP_
BIN2NUM - Convert a byte array to a numeric value.
- OP_
BOOLAND - Push 1 if both top two items are non-zero, 0 otherwise.
- OP_
BOOLOR - Push 1 if either of the top two items is non-zero, 0 otherwise.
- OP_CAT
- Concatenate the top two stack items.
- OP_
CHECKLOCKTIMEVERIFY - Verify that the transaction locktime is at least the given value (BTC only, NOP in BSV).
- OP_
CHECKMULTISIG - Pop N public keys and M signatures, push 1 if all signatures are valid, 0 otherwise.
- OP_
CHECKMULTISIGVERIFY - Same as OP_CHECKMULTISIG, then OP_VERIFY. Marks transaction invalid if check fails.
- OP_
CHECKSEQUENCEVERIFY - Verify that the input sequence number is at least the given value (BTC only, NOP in BSV).
- OP_
CHECKSIG - Pop a public key and signature, push 1 if the signature is valid, 0 otherwise.
- OP_
CHECKSIGVERIFY - Same as OP_CHECKSIG, then OP_VERIFY. Marks transaction invalid if signature check fails.
- OP_
CODESEPARATOR - Mark the beginning of signature-checked code.
- OP_
DATA_ 1 - Push the next 1 byte onto the stack.
- OP_
DATA_ 2 - Push the next 2 bytes onto the stack.
- OP_
DATA_ 3 - Push the next 3 bytes onto the stack.
- OP_
DATA_ 4 - Push the next 4 bytes onto the stack.
- OP_
DATA_ 5 - Push the next 5 bytes onto the stack.
- OP_
DATA_ 6 - Push the next 6 bytes onto the stack.
- OP_
DATA_ 7 - Push the next 7 bytes onto the stack.
- OP_
DATA_ 8 - Push the next 8 bytes onto the stack.
- OP_
DATA_ 9 - Push the next 9 bytes onto the stack.
- OP_
DATA_ 10 - Push the next 10 bytes onto the stack.
- OP_
DATA_ 11 - Push the next 11 bytes onto the stack.
- OP_
DATA_ 12 - Push the next 12 bytes onto the stack.
- OP_
DATA_ 13 - Push the next 13 bytes onto the stack.
- OP_
DATA_ 14 - Push the next 14 bytes onto the stack.
- OP_
DATA_ 15 - Push the next 15 bytes onto the stack.
- OP_
DATA_ 16 - Push the next 16 bytes onto the stack.
- OP_
DATA_ 17 - Push the next 17 bytes onto the stack.
- OP_
DATA_ 18 - Push the next 18 bytes onto the stack.
- OP_
DATA_ 19 - Push the next 19 bytes onto the stack.
- OP_
DATA_ 20 - Push the next 20 bytes onto the stack.
- OP_
DATA_ 21 - Push the next 21 bytes onto the stack.
- OP_
DATA_ 22 - Push the next 22 bytes onto the stack.
- OP_
DATA_ 23 - Push the next 23 bytes onto the stack.
- OP_
DATA_ 24 - Push the next 24 bytes onto the stack.
- OP_
DATA_ 25 - Push the next 25 bytes onto the stack.
- OP_
DATA_ 26 - Push the next 26 bytes onto the stack.
- OP_
DATA_ 27 - Push the next 27 bytes onto the stack.
- OP_
DATA_ 28 - Push the next 28 bytes onto the stack.
- OP_
DATA_ 29 - Push the next 29 bytes onto the stack.
- OP_
DATA_ 30 - Push the next 30 bytes onto the stack.
- OP_
DATA_ 31 - Push the next 31 bytes onto the stack.
- OP_
DATA_ 32 - Push the next 32 bytes onto the stack.
- OP_
DATA_ 33 - Push the next 33 bytes onto the stack.
- OP_
DATA_ 34 - Push the next 34 bytes onto the stack.
- OP_
DATA_ 35 - Push the next 35 bytes onto the stack.
- OP_
DATA_ 36 - Push the next 36 bytes onto the stack.
- OP_
DATA_ 37 - Push the next 37 bytes onto the stack.
- OP_
DATA_ 38 - Push the next 38 bytes onto the stack.
- OP_
DATA_ 39 - Push the next 39 bytes onto the stack.
- OP_
DATA_ 40 - Push the next 40 bytes onto the stack.
- OP_
DATA_ 41 - Push the next 41 bytes onto the stack.
- OP_
DATA_ 42 - Push the next 42 bytes onto the stack.
- OP_
DATA_ 43 - Push the next 43 bytes onto the stack.
- OP_
DATA_ 44 - Push the next 44 bytes onto the stack.
- OP_
DATA_ 45 - Push the next 45 bytes onto the stack.
- OP_
DATA_ 46 - Push the next 46 bytes onto the stack.
- OP_
DATA_ 47 - Push the next 47 bytes onto the stack.
- OP_
DATA_ 48 - Push the next 48 bytes onto the stack.
- OP_
DATA_ 49 - Push the next 49 bytes onto the stack.
- OP_
DATA_ 50 - Push the next 50 bytes onto the stack.
- OP_
DATA_ 51 - Push the next 51 bytes onto the stack.
- OP_
DATA_ 52 - Push the next 52 bytes onto the stack.
- OP_
DATA_ 53 - Push the next 53 bytes onto the stack.
- OP_
DATA_ 54 - Push the next 54 bytes onto the stack.
- OP_
DATA_ 55 - Push the next 55 bytes onto the stack.
- OP_
DATA_ 56 - Push the next 56 bytes onto the stack.
- OP_
DATA_ 57 - Push the next 57 bytes onto the stack.
- OP_
DATA_ 58 - Push the next 58 bytes onto the stack.
- OP_
DATA_ 59 - Push the next 59 bytes onto the stack.
- OP_
DATA_ 60 - Push the next 60 bytes onto the stack.
- OP_
DATA_ 61 - Push the next 61 bytes onto the stack.
- OP_
DATA_ 62 - Push the next 62 bytes onto the stack.
- OP_
DATA_ 63 - Push the next 63 bytes onto the stack.
- OP_
DATA_ 64 - Push the next 64 bytes onto the stack.
- OP_
DATA_ 65 - Push the next 65 bytes onto the stack.
- OP_
DATA_ 66 - Push the next 66 bytes onto the stack.
- OP_
DATA_ 67 - Push the next 67 bytes onto the stack.
- OP_
DATA_ 68 - Push the next 68 bytes onto the stack.
- OP_
DATA_ 69 - Push the next 69 bytes onto the stack.
- OP_
DATA_ 70 - Push the next 70 bytes onto the stack.
- OP_
DATA_ 71 - Push the next 71 bytes onto the stack.
- OP_
DATA_ 72 - Push the next 72 bytes onto the stack.
- OP_
DATA_ 73 - Push the next 73 bytes onto the stack.
- OP_
DATA_ 74 - Push the next 74 bytes onto the stack.
- OP_
DATA_ 75 - Push the next 75 bytes onto the stack.
- OP_
DEPTH - Push the number of items on the stack onto the stack.
- OP_DIV
- Pop two items, push the integer quotient of the second divided by the top.
- OP_DROP
- Remove the top stack item.
- OP_DUP
- Duplicate the top stack item.
- OP_ELSE
- Execute the following statements if the preceding OP_IF/OP_NOTIF was not executed.
- OP_
ENDIF - End an if/else block.
- OP_
EQUAL - Push 1 if the top two stack items are exactly equal, 0 otherwise.
- OP_
EQUALVERIFY - Same as OP_EQUAL, then OP_VERIFY. Marks transaction invalid if not equal.
- OP_
FALSE - Push an empty byte array (false/zero) onto the stack. Alias for
OP_0. - OP_
FROMALTSTACK - Move the top item from the alt stack to the main stack.
- OP_
GREATERTHAN - Push 1 if the second item is greater than the top item, 0 otherwise.
- OP_
GREATERTHANOREQUAL - Push 1 if the second item is greater than or equal to the top item, 0 otherwise.
- OP_
HASH160 - Hash the top item with SHA-256 then RIPEMD-160 (Bitcoin address hash).
- OP_
HASH256 - Hash the top item with double SHA-256 (Bitcoin transaction hash).
- OP_IF
- Execute the following statements if the top stack value is true (non-zero).
- OP_
IFDUP - Duplicate the top stack item if it is non-zero.
- OP_
INVALIDOPCODE - Invalid opcode that always causes script failure.
- OP_
INVERT - Flip all bits of the top stack item.
- OP_
LESSTHAN - Push 1 if the second item is less than the top item, 0 otherwise.
- OP_
LESSTHANOREQUAL - Push 1 if the second item is less than or equal to the top item, 0 otherwise.
- OP_
LSHIFT - Left-shift the second item by the number of bits given by the top item.
- OP_MAX
- Push the larger of the top two stack items.
- OP_MIN
- Push the smaller of the top two stack items.
- OP_MOD
- Pop two items, push the remainder of the second divided by the top.
- OP_MUL
- Pop two items, push their product.
- OP_
NEGATE - Negate the top stack item (flip its sign).
- OP_NIP
- Remove the second-to-top stack item.
- OP_NOP
- Do nothing.
- OP_NOP1
- No operation (reserved for future soft-fork upgrades).
- OP_NOP2
- No operation (reserved for future soft-fork upgrades). Alias for OP_CHECKLOCKTIMEVERIFY in BTC.
- OP_NOP3
- No operation (reserved for future soft-fork upgrades). Alias for OP_CHECKSEQUENCEVERIFY in BTC.
- OP_NOP4
- No operation (reserved for future soft-fork upgrades).
- OP_NOP5
- No operation (reserved for future soft-fork upgrades).
- OP_NOP6
- No operation (reserved for future soft-fork upgrades).
- OP_NOP7
- No operation (reserved for future soft-fork upgrades).
- OP_NOP8
- No operation (reserved for future soft-fork upgrades).
- OP_NOP9
- No operation (reserved for future soft-fork upgrades).
- OP_
NOP10 - No operation (reserved for future soft-fork upgrades).
- OP_NOT
- Push 1 if the top item is 0, push 0 otherwise.
- OP_
NOTIF - Execute the following statements if the top stack value is false (zero).
- OP_
NUM2BIN - Convert the top numeric value to a byte array of the specified length.
- OP_
NUMEQUAL - Push 1 if the top two items are numerically equal, 0 otherwise.
- OP_
NUMEQUALVERIFY - Same as OP_NUMEQUAL, then OP_VERIFY. Marks transaction invalid if not equal.
- OP_
NUMNOTEQUAL - Push 1 if the top two items are not numerically equal, 0 otherwise.
- OP_OR
- Bitwise OR of the top two stack items.
- OP_OVER
- Copy the second-to-top stack item to the top.
- OP_PICK
- Copy the item N positions back in the stack to the top.
- OP_
PUBKEY - Internal pseudo-opcode representing a public key (used in template matching).
- OP_
PUBKEYHASH - Internal pseudo-opcode representing a public key hash (used in template matching).
- OP_
PUBKEYS - Internal pseudo-opcode representing multiple public keys (used in template matching).
- OP_
PUSHDAT A1 - Read the next 1 byte as a length N, then push the next N bytes onto the stack.
- OP_
PUSHDAT A2 - Read the next 2 bytes as a little-endian length N, then push the next N bytes onto the stack.
- OP_
PUSHDAT A4 - Read the next 4 bytes as a little-endian length N, then push the next N bytes onto the stack.
- OP_
RESERVED - Reserved opcode. Transaction is invalid if executed.
- OP_
RESERVE D1 - Reserved opcode. Transaction is invalid if executed.
- OP_
RESERVE D2 - Reserved opcode. Transaction is invalid if executed.
- OP_
RETURN - Mark the transaction output as unspendable (provably prunable).
- OP_
RIPEM D160 - Hash the top item with RIPEMD-160.
- OP_ROLL
- Move the item N positions back in the stack to the top.
- OP_ROT
- Rotate the top three items on the stack (third item moves to top).
- OP_
RSHIFT - Right-shift the second item by the number of bits given by the top item.
- OP_SHA1
- Hash the top item with SHA-1.
- OP_
SHA256 - Hash the top item with SHA-256.
- OP_SIZE
- Push the byte length of the top stack item (without popping it).
- OP_
SMALLINTEGER - Internal pseudo-opcode representing a small integer (used in template matching).
- OP_
SPLIT - Split the second-to-top item at position given by the top item.
- OP_SUB
- Pop two items, push the second minus the top.
- OP_SWAP
- Swap the top two stack items.
- OP_
TOALTSTACK - Move the top stack item to the alt stack.
- OP_TRUE
- Push the number 1 onto the stack. Alias for
OP_1. - OP_TUCK
- Copy the top stack item and insert it below the second-to-top item.
- OP_
UNKNOW N186 - Unknown opcode 186 (0xba). Undefined behavior.
- OP_
UNKNOW N187 - Unknown opcode 187 (0xbb). Undefined behavior.
- OP_
UNKNOW N188 - Unknown opcode 188 (0xbc). Undefined behavior.
- OP_
UNKNOW N189 - Unknown opcode 189 (0xbd). Undefined behavior.
- OP_
UNKNOW N190 - Unknown opcode 190 (0xbe). Undefined behavior.
- OP_
UNKNOW N191 - Unknown opcode 191 (0xbf). Undefined behavior.
- OP_
UNKNOW N192 - Unknown opcode 192 (0xc0). Undefined behavior.
- OP_
UNKNOW N193 - Unknown opcode 193 (0xc1). Undefined behavior.
- OP_
UNKNOW N194 - Unknown opcode 194 (0xc2). Undefined behavior.
- OP_
UNKNOW N195 - Unknown opcode 195 (0xc3). Undefined behavior.
- OP_
UNKNOW N196 - Unknown opcode 196 (0xc4). Undefined behavior.
- OP_
UNKNOW N197 - Unknown opcode 197 (0xc5). Undefined behavior.
- OP_
UNKNOW N198 - Unknown opcode 198 (0xc6). Undefined behavior.
- OP_
UNKNOW N199 - Unknown opcode 199 (0xc7). Undefined behavior.
- OP_
UNKNOW N200 - Unknown opcode 200 (0xc8). Undefined behavior.
- OP_
UNKNOW N201 - Unknown opcode 201 (0xc9). Undefined behavior.
- OP_
UNKNOW N202 - Unknown opcode 202 (0xca). Undefined behavior.
- OP_
UNKNOW N203 - Unknown opcode 203 (0xcb). Undefined behavior.
- OP_
UNKNOW N204 - Unknown opcode 204 (0xcc). Undefined behavior.
- OP_
UNKNOW N205 - Unknown opcode 205 (0xcd). Undefined behavior.
- OP_
UNKNOW N206 - Unknown opcode 206 (0xce). Undefined behavior.
- OP_
UNKNOW N207 - Unknown opcode 207 (0xcf). Undefined behavior.
- OP_
UNKNOW N208 - Unknown opcode 208 (0xd0). Undefined behavior.
- OP_
UNKNOW N209 - Unknown opcode 209 (0xd1). Undefined behavior.
- OP_
UNKNOW N210 - Unknown opcode 210 (0xd2). Undefined behavior.
- OP_
UNKNOW N211 - Unknown opcode 211 (0xd3). Undefined behavior.
- OP_
UNKNOW N212 - Unknown opcode 212 (0xd4). Undefined behavior.
- OP_
UNKNOW N213 - Unknown opcode 213 (0xd5). Undefined behavior.
- OP_
UNKNOW N214 - Unknown opcode 214 (0xd6). Undefined behavior.
- OP_
UNKNOW N215 - Unknown opcode 215 (0xd7). Undefined behavior.
- OP_
UNKNOW N216 - Unknown opcode 216 (0xd8). Undefined behavior.
- OP_
UNKNOW N217 - Unknown opcode 217 (0xd9). Undefined behavior.
- OP_
UNKNOW N218 - Unknown opcode 218 (0xda). Undefined behavior.
- OP_
UNKNOW N219 - Unknown opcode 219 (0xdb). Undefined behavior.
- OP_
UNKNOW N220 - Unknown opcode 220 (0xdc). Undefined behavior.
- OP_
UNKNOW N221 - Unknown opcode 221 (0xdd). Undefined behavior.
- OP_
UNKNOW N222 - Unknown opcode 222 (0xde). Undefined behavior.
- OP_
UNKNOW N223 - Unknown opcode 223 (0xdf). Undefined behavior.
- OP_
UNKNOW N224 - Unknown opcode 224 (0xe0). Undefined behavior.
- OP_
UNKNOW N225 - Unknown opcode 225 (0xe1). Undefined behavior.
- OP_
UNKNOW N226 - Unknown opcode 226 (0xe2). Undefined behavior.
- OP_
UNKNOW N227 - Unknown opcode 227 (0xe3). Undefined behavior.
- OP_
UNKNOW N228 - Unknown opcode 228 (0xe4). Undefined behavior.
- OP_
UNKNOW N229 - Unknown opcode 229 (0xe5). Undefined behavior.
- OP_
UNKNOW N230 - Unknown opcode 230 (0xe6). Undefined behavior.
- OP_
UNKNOW N231 - Unknown opcode 231 (0xe7). Undefined behavior.
- OP_
UNKNOW N232 - Unknown opcode 232 (0xe8). Undefined behavior.
- OP_
UNKNOW N233 - Unknown opcode 233 (0xe9). Undefined behavior.
- OP_
UNKNOW N234 - Unknown opcode 234 (0xea). Undefined behavior.
- OP_
UNKNOW N235 - Unknown opcode 235 (0xeb). Undefined behavior.
- OP_
UNKNOW N236 - Unknown opcode 236 (0xec). Undefined behavior.
- OP_
UNKNOW N237 - Unknown opcode 237 (0xed). Undefined behavior.
- OP_
UNKNOW N238 - Unknown opcode 238 (0xee). Undefined behavior.
- OP_
UNKNOW N239 - Unknown opcode 239 (0xef). Undefined behavior.
- OP_
UNKNOW N240 - Unknown opcode 240 (0xf0). Undefined behavior.
- OP_
UNKNOW N241 - Unknown opcode 241 (0xf1). Undefined behavior.
- OP_
UNKNOW N242 - Unknown opcode 242 (0xf2). Undefined behavior.
- OP_
UNKNOW N243 - Unknown opcode 243 (0xf3). Undefined behavior.
- OP_
UNKNOW N244 - Unknown opcode 244 (0xf4). Undefined behavior.
- OP_
UNKNOW N245 - Unknown opcode 245 (0xf5). Undefined behavior.
- OP_
UNKNOW N246 - Unknown opcode 246 (0xf6). Undefined behavior.
- OP_
UNKNOW N247 - Unknown opcode 247 (0xf7). Undefined behavior.
- OP_
UNKNOW N248 - Unknown opcode 248 (0xf8). Undefined behavior.
- OP_
UNKNOW N249 - Unknown opcode 249 (0xf9). Undefined behavior.
- OP_
UNKNOW N252 - Unknown opcode 252 (0xfc). Undefined behavior.
- OP_VER
- Reserved opcode. Transaction is invalid if executed.
- OP_
VERIF - Reserved opcode. Transaction is invalid even if not executed.
- OP_
VERIFY - Mark the transaction as invalid if the top stack value is false.
- OP_
VERNOTIF - Reserved opcode. Transaction is invalid even if not executed.
- OP_
WITHIN - Push 1 if the third item is within the range [second, top), 0 otherwise.
- OP_XOR
- Bitwise XOR of the top two stack items.
Functions§
- is_
push_ data - Check if an opcode is a push data opcode (OP_DATA_1..OP_PUSHDATA4).
- is_
small_ int_ op - Check if an opcode represents a small integer (OP_0 or OP_1..OP_16).
- opcode_
to_ string - Convert an opcode byte value to its string representation for ASM output.
- string_
to_ opcode - Convert an opcode name string to its byte value.