> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/opcodes-used-in-bitcoin-script.md).

# Opcodes used in Bitcoin Script

This is a list of all Script words, also known as opcodes, commands, or functions. OP\_NOP1-OP\_NOP10 were originally set aside to be used when HASH and other security functions become insecure due to improvements in computing. False is zero or negative zero (using any number of bytes) or an empty array, and True is anything else.

## 1. Constants

When talking about scripts, these value-pushing words are usually omitted.

| Word                | Opcode | Hex       | Input     | Output        | Description                                                                                             |
| ------------------- | ------ | --------- | --------- | ------------- | ------------------------------------------------------------------------------------------------------- |
| OP\_0, OP\_FALSE    | 0      | 0x00      | Nothing.  | (empty value) | An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.) |
| Pushdata Bytelength | 1-75   | 0x01-0x4b | (special) | data          | The next **opcode** bytes is data to be pushed onto the stack                                           |
| OP\_PUSHDATA1       | 76     | 0x4c      | (special) | data          | The next byte contains the number of bytes to be pushed onto the stack.                                 |
| OP\_PUSHDATA2       | 77     | 0x4d      | (special) | data          | The next two bytes contain the number of bytes to be pushed onto the stack in little endian order.      |
| OP\_PUSHDATA4       | 78     | 0x4e      | (special) | data          | The next four bytes contain the number of bytes to be pushed onto the stack in little endian order.     |
| OP\_1NEGATE         | 79     | 0x4f      | Nothing.  | -1            | The number -1 is pushed onto the stack.                                                                 |
| OP\_1, OP\_TRUE     | 81     | 0x51      | Nothing.  | 1             | The number 1 is pushed onto the stack.                                                                  |
| OP\_2-OP\_16        | 82-96  | 0x52-0x60 | Nothing.  | 2-16          | The number in the word name (2-16) is pushed onto the stack.                                            |

## 2. Flow control

| Word         | Opcode | Hex  | Input                                                                                                                                                                                                                                                                                                                                     | Output                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------ | ------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| OP\_NOP      | 97     | 0x61 | Nothing                                                                                                                                                                                                                                                                                                                                   | Nothing                                                 | Does nothing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| OP\_VER      | 98     | 0x62 | Nothing                                                                                                                                                                                                                                                                                                                                   | Transaction version                                     | Pushes the executing transaction's version onto the stack. The transaction version is the first four bytes of the transaction containing the executing script.                                                                                                                                                                                                                                                                                                                                                                       |
| OP\_IF       | 99     | 0x63 | \[expression] IF [1](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ENDIF OR \[expression] IF [1](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ELSE [2](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ENDIF    |                                                         | If the top stack value is TRUE, statement 1 is executed. If the top stack value is FALSE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.                                                                                                                                                                                                                                                                                                                  |
| OP\_NOTIF    | 100    | 0x64 | \[expression] NOTIF [1](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ENDIF OR \[expression] IF [1](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ELSE [2](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ENDIF |                                                         | If the top stack value is FALSE, statement 1 is executed. If the top stack value is TRUE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.                                                                                                                                                                                                                                                                                                                  |
| OP\_VERIF    | 101    | 0x65 | comparison value                                                                                                                                                                                                                                                                                                                          | (conditional execution)                                 | Compares the top of stack with the executing transaction's version using greater-than-or-equal comparison as part of an if-then-else expression. Logically equivalent to OP\_VER OP\_GREATERTHANOREQUAL OP\_IF.                                                                                                                                                                                                                                                                                                                      |
| OP\_VERNOTIF | 102    | 0x66 | comparison value                                                                                                                                                                                                                                                                                                                          | (conditional execution)                                 | Compares the top of stack with the executing transaction's version using negated greater-than-or-equal comparison as part of an if-then-else expression. Logically equivalent to OP\_VER OP\_GREATERTHANOREQUAL OP\_NOTIF.                                                                                                                                                                                                                                                                                                           |
| OP\_ELSE     | 103    | 0x67 | \[expression] IF [1](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ELSE [2](https://github.com/bsv-blockchain/gitbook-wiki/tree/gitbook/pages/statement/README.md) ENDIF                                                                                                                         |                                                         | If the preceding IF or NOTIF check was not valid then statement 2 is executed.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| OP\_ENDIF    | 104    | 0x68 | \[expression] IF ELSE ENDIF                                                                                                                                                                                                                                                                                                               |                                                         | Ends an if/else block. All blocks must end, or the transaction is **invalid**. An OP\_ENDIF without a prior matching OP\_IF or OP\_NOTIF is also **invalid**.                                                                                                                                                                                                                                                                                                                                                                        |
| OP\_VERIFY   | 105    | 0x69 | True / false                                                                                                                                                                                                                                                                                                                              | Nothing / *fail*                                        | **Marks transaction as invalid** if top stack value is not true. The top stack value is removed.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OP\_RETURN   | 106    | 0x6a | Nothing                                                                                                                                                                                                                                                                                                                                   | **Ends script with top value on stack as final result** | OP\_RETURN can also be used to create "False Return" outputs with a scriptPubKey consisting of OP\_FALSE OP\_RETURN followed by data. Such outputs are provably unspendable and should be given a value of zero Satoshis. These outputs can be pruned from storage in the UTXO set, reducing its size. The BSV Blockchain network supports multiple FALSE RETURN outputs in a given transaction. Since the Genesis upgrade in February 2020, miners have been free to mine transactions containing FALSE RETURN outputs of any size. |

## 3. Stack

| Word             | Opcode | Hex  | Input             | Output             | Description                                                                            |
| ---------------- | ------ | ---- | ----------------- | ------------------ | -------------------------------------------------------------------------------------- |
| OP\_TOALTSTACK   | 107    | 0x6b | x1                | (alt)x1            | Puts the input onto the top of the alt stack. Removes it from the main stack.          |
| OP\_FROMALTSTACK | 108    | 0x6c | (alt)x1           | x1                 | Puts the input onto the top of the main stack. Removes it from the alt stack.          |
| OP\_2DROP        | 109    | 0x6d | x1 x2             | Nothing            | Removes the top two stack items.                                                       |
| OP\_2DUP         | 110    | 0x6e | x1 x2             | x1 x2 x1 x2        | Duplicates the top two stack items.                                                    |
| OP\_3DUP         | 111    | 0x6f | x1 x2 x3          | x1 x2 x3 x1 x2 x3  | Duplicates the top three stack items.                                                  |
| OP\_2OVER        | 112    | 0x70 | x1 x2 x3 x4       | x1 x2 x3 x4 x1 x2  | Copies the pair of items two spaces back in the stack to the front.                    |
| OP\_2ROT         | 113    | 0x71 | x1 x2 x3 x4 x5 x6 | x3 x4 x5 x6 x1 x2  | The fifth and sixth items back are moved to the top of the stack.                      |
| OP\_2SWAP        | 114    | 0x72 | x1 x2 x3 x4       | x3 x4 x1 x2        | Swaps the top two pairs of items.                                                      |
| OP\_IFDUP        | 115    | 0x73 | x                 | x / x x            | If the top stack value is not 0, duplicate it.                                         |
| OP\_DEPTH        | 116    | 0x74 | Nothing           |                    | Counts the number of stack items onto the stack and places the value on the top        |
| OP\_DROP         | 117    | 0x75 | x                 | Nothing            | Removes the top stack item.                                                            |
| OP\_DUP          | 118    | 0x76 | x                 | x x                | Duplicates the top stack item.                                                         |
| OP\_NIP          | 119    | 0x77 | x1 x2             | x2                 | Removes the second-to-top stack item.                                                  |
| OP\_OVER         | 120    | 0x78 | x1 x2             | x1 x2 x1           | Copies the second-to-top stack item to the top.                                        |
| OP\_PICK         | 121    | 0x79 | xn ... x2 x1 x0   | xn ... x2 x1 x0 xn | The item **n** back in the stack is copied to the top.                                 |
| OP\_ROLL         | 122    | 0x7a | xn ... x2 x1 x0   | ... x2 x1 x0 xn    | The item **n** back in the stack is moved to the top.                                  |
| OP\_ROT          | 123    | 0x7b | x1 x2 x3          | x2 x3 x1           | The top three items on the stack are rotated to the left.                              |
| OP\_SWAP         | 124    | 0x7c | x1 x2             | x2 x1              | The top two items on the stack are swapped.                                            |
| OP\_TUCK         | 125    | 0x7d | x1 x2             | x2 x1 x2           | The item at the top of the stack is copied and inserted before the second-to-top item. |

## 4. Data Manipulation

| Word        | Opcode | Hex  | Input | Output  | Description                                                                    |
| ----------- | ------ | ---- | ----- | ------- | ------------------------------------------------------------------------------ |
| OP\_CAT     | 126    | 0x7e | x1 x2 | out     | Concatenates two strings.                                                      |
| OP\_SPLIT   | 127    | 0x7f | x n   | x1 x2   | Splits byte sequence x at position n.                                          |
| OP\_NUM2BIN | 128    | 0x80 | a b   | out     | Converts numeric value a into byte sequence of length b.                       |
| OP\_BIN2NUM | 129    | 0x81 | x     | out     | Converts byte sequence x into a numeric value.                                 |
| OP\_SIZE    | 130    | 0x82 | in    | in size | Pushes the string length of the top element of the stack (without popping it). |

## 5. Bitwise logic

| Word            | Opcode | Hex  | Input | Output             | Description                                                            |
| --------------- | ------ | ---- | ----- | ------------------ | ---------------------------------------------------------------------- |
| OP\_INVERT      | 131    | 0x83 | in    | out                | **DISABLED.** Flips all of the bits in the input.                      |
| OP\_AND         | 132    | 0x84 | x1 x2 | out                | **DISABLED.** Boolean **and** between each bit in the inputs.          |
| OP\_OR          | 133    | 0x85 | x1 x2 | out                | **DISABLED.** Boolean **or** between each bit in the inputs.           |
| OP\_XOR         | 134    | 0x86 | x1 x2 | out                | **DISABLED.** Boolean **exclusive or** between each bit in the inputs. |
| OP\_EQUAL       | 135    | 0x87 | x1 x2 | True / false       | Returns 1 if the inputs are exactly equal, 0 otherwise.                |
| OP\_EQUALVERIFY | 136    | 0x88 | x1 x2 | Nothing / **fail** | Same as OP\_EQUAL, but runs OP\_VERIFY afterward.                      |

## 6. Arithmetic

BitcoinScript supports arithmetic on bignum values.

A bignum is a byte sequence that represents a numeric value. The length of the byte sequence must be less than or equal to 750,000 bytes. Byte sequences larger than 750,000 bytes are valid in Bitcoin however current rules dictate that they are not recognised as a valid numeric value.

Note that while some operations require parameters to be valid numeric values, they may produce byte sequences which are not valid numeric values (for example, OP\_MUL may produce a byte sequence which is too large to validly represent a numeric value).

| Word                   | Opcode | Hex  | Input     | Output             | Description                                                                                                   |
| ---------------------- | ------ | ---- | --------- | ------------------ | ------------------------------------------------------------------------------------------------------------- |
| OP\_1ADD               | 139    | 0x8b | in        | out                | 1 is added to the input.                                                                                      |
| OP\_1SUB               | 140    | 0x8c | in        | out                | 1 is subtracted from the input.                                                                               |
| OP\_2MUL               | 141    | 0x8d | in        | out                | **DISABLED.** The input is multiplied by 2.                                                                   |
| OP\_2DIV               | 142    | 0x8e | in        | out                | **DISABLED.** The input is divided by 2.                                                                      |
| OP\_NEGATE             | 143    | 0x8f | in        | out                | The sign of the input is flipped.                                                                             |
| OP\_ABS                | 144    | 0x90 | in        | out                | The input is made positive.                                                                                   |
| OP\_NOT                | 145    | 0x91 | in        | out                | If the input is 0 or 1, it is flipped. Otherwise the output will be 0.                                        |
| OP\_0NOTEQUAL          | 146    | 0x92 | in        | out                | Returns 0 if the input is 0. 1 otherwise.                                                                     |
| OP\_ADD                | 147    | 0x93 | a b       | out                | a is added to b.                                                                                              |
| OP\_SUB                | 148    | 0x94 | a b       | out                | b is subtracted from a.                                                                                       |
| OP\_MUL                | 149    | 0x95 | a b       | out                | **DISABLED.** a is multiplied by b.                                                                           |
| OP\_DIV                | 150    | 0x96 | a b       | out                | **DISABLED.** a is divided by b.                                                                              |
| OP\_MOD                | 151    | 0x97 | a b       | out                | **DISABLED.** Returns the remainder after dividing a by b.                                                    |
| OP\_LSHIFT             | 152    | 0x98 | a b       | out                | **DISABLED.** Logical left shift b bits. Sign data is discarded.                                              |
| OP\_RSHIFT             | 153    | 0x99 | a b       | out                | **DISABLED.** Logical right shift b bits. Sign data is discarded.                                             |
| OP\_LSHIFTNUM          | 182    | 0xb6 | a b       | out                | Arithmetic left shift of value a by b bits. Preserves the sign bit (restores original LSHIFT functionality).  |
| OP\_RSHIFTNUM          | 183    | 0xb7 | a b       | out                | Arithmetic right shift of value a by b bits. Preserves the sign bit (restores original RSHIFT functionality). |
| OP\_BOOLAND            | 154    | 0x9a | a b       | out                | If both a and b are not 0, the output is 1. Otherwise 0.                                                      |
| OP\_BOOLOR             | 155    | 0x9b | a b       | out                | If a or b is not 0, the output is 1. Otherwise 0.                                                             |
| OP\_NUMEQUAL           | 156    | 0x9c | a b       | out                | Returns 1 if the numbers are equal, 0 otherwise.                                                              |
| OP\_NUMEQUALVERIFY     | 157    | 0x9d | a b       | Nothing / **fail** | Same as OP\_NUMEQUAL, but runs OP\_VERIFY afterward.                                                          |
| OP\_NUMNOTEQUAL        | 158    | 0x9e | a b       | out                | Returns 1 if the numbers are not equal, 0 otherwise.                                                          |
| OP\_LESSTHAN           | 159    | 0x9f | a b       | out                | Returns 1 if a is less than b, 0 otherwise.                                                                   |
| OP\_GREATERTHAN        | 160    | 0xa0 | a b       | out                | Returns 1 if a is greater than b, 0 otherwise.                                                                |
| OP\_LESSTHANOREQUAL    | 161    | 0xa1 | a b       | out                | Returns 1 if a is less than or equal to b, 0 otherwise.                                                       |
| OP\_GREATERTHANOREQUAL | 162    | 0xa2 | a b       | out                | Returns 1 if a is greater than or equal to b, 0 otherwise.                                                    |
| OP\_MIN                | 163    | 0xa3 | a b       | out                | Returns the smaller of a and b.                                                                               |
| OP\_MAX                | 164    | 0xa4 | a b       | out                | Returns the larger of a and b.                                                                                |
| OP\_WITHIN             | 165    | 0xa5 | x min max | out                | Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.                                   |

## 7. Cryptography

| Word                    | Opcode | Hex  | Input                         | Output           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ----------------------- | ------ | ---- | ----------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OP\_RIPEMD160           | 166    | 0xa6 | in                            | hash             | The input is hashed using RIPEMD-160.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| OP\_SHA1                | 167    | 0xa7 | in                            | hash             | The input is hashed using SHA-1.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| OP\_SHA256              | 168    | 0xa8 | in                            | hash             | The input is hashed using SHA-256.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| OP\_HASH160             | 169    | 0xa9 | in                            | hash             | The input is hashed twice: first with SHA-256 and then with RIPEMD-160.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| OP\_HASH256             | 170    | 0xaa | in                            | hash             | The input is hashed two times with SHA-256.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| OP\_CODESEPARATOR       | 171    | 0xab | Nothing                       | Nothing          | All of the signature checking words will only match signatures to the data after the most recently-executed OP\_CODESEPARATOR.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| OP\_CHECKSIG            | 172    | 0xac | sig pubkey                    | True / false     | The entire transaction's outputs, inputs, and script (from the most recently-executed OP\_CODESEPARATOR to the end) are hashed. The signature used by OP\_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| OP\_CHECKSIGVERIFY      | 173    | 0xad | sig pubkey                    | Nothing / *fail* | Same as OP\_CHECKSIG, but OP\_VERIFY is executed afterward.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| OP\_CHECKMULTISIG       | 174    | 0xae | x sig1 sig2 ... pub1 pub2     | True / False     | Compares the first signature against each public key until it finds an ECDSA match. Starting with the subsequent public key, it compares the second signature against each remaining public key until it finds an ECDSA match. The process is repeated until all signatures have been checked or not enough public keys remain to produce a successful result. All signatures need to match a public key. Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the scriptSig using the same order as their corresponding public keys were placed in the scriptPubKey or redeemScript. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, an extra unused value (x) is removed from the stack. Script spenders must account for this by adding a junk value (typically zero) to the stack. |
| OP\_CHECKMULTISIGVERIFY | 175    | 0xaf | x sig1 sig2 ... pub1 pub2 ... | Nothing / *fail* | Same as OP\_CHECKMULTISIG, but OP\_VERIFY is executed afterward.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

## 8. Used NOP opcode identifiers

In Bitcoin's history, new opcodes were added that used reserved NO\_OP opcode identifiers. These opcodes have been reverted to the original OP\_NOP functionality.

| Word                                          | Opcode | Hex  | Input                   | Output                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------------------------- | ------ | ---- | ----------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OP\_NOP2 (previously OP\_CHECKLOCKTIMEVERIFY) | 177    | 0xb1 | Nothing (Previously: x) | Nothing (Previously: x or fail) | NO OPERATION **Evaluation process for UTXOs that pre-date genesis: Mark transaction as invalid if the top stack item is greater than the transaction's nLockTime field, otherwise script evaluation continues as though an OP\_NOP was executed. Transaction is also invalid if 1. the stack is empty; or 2. the top stack item is negative; or 3. the top stack item is greater than or equal to 500000000 while the transaction's nLockTime field is less than 500000000, or vice versa; or 4. the input's nSequence field is equal to 0xffffffff. The precise semantics are described in** [**BIP 0065**](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki)**.** |
| OP\_NOP3 (previously OP\_CHECKSEQUENCEVERIFY) | 178    | 0xb2 | Nothing (Previously: x) | Nothing (Previously: x or fail) | NO OPERATION **Evaluation process for UTXOs that pre-date genesis: Mark transaction as invalid if the relative lock time of the input (enforced by** [**BIP 0068**](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki) **with nSequence) is not equal to or longer than the value of the top stack item. The precise semantics are described in** [**BIP 0112**](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki)**.**                                                                                                                                                                                                                                |

## 9. String Operations

| Word       | Opcode | Hex  | Input                               | Output    | Description                                                                                                                                                                                                                                                                                                        |
| ---------- | ------ | ---- | ----------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| OP\_SUBSTR | 179    | 0xb3 | string, start index, desired length | substring | Returns substring defined by start index and length. A zero-length source string generates an error. A negative length generates an error. If the specified length is greater than the source string, the opcode generates an error. Example: "BSV Blockchain" OP\_4 OP\_5 OP\_SUBSTR leaves "Block" on the stack. |
| OP\_LEFT   | 180    | 0xb4 | string, desired length              | substring | Produces a substring consisting only of the specified number of leftmost characters. Zero-length strings are allowed. Example: "BSV Blockchain" OP\_3 OP\_LEFT leaves "BSV" on the stack.                                                                                                                          |
| OP\_RIGHT  | 181    | 0xb5 | string, desired length              | substring | Produces a substring consisting only of the specified number of rightmost characters. Zero-length strings are allowed. Example: "BSV Blockchain" OP\_5 OP\_RIGHT leaves "chain" on the stack.                                                                                                                      |

## 10. Chronicle Release Opcodes

The Chronicle release restored several opcodes that were previously disabled. These opcodes expand Bitcoin Script's capabilities:

| Word          | Opcode | Hex  | Input                       | Output                  | Description                                                                                  |
| ------------- | ------ | ---- | --------------------------- | ----------------------- | -------------------------------------------------------------------------------------------- |
| OP\_VER       | 98     | 0x62 | Nothing                     | Transaction version     | Pushes the executing transaction's version onto the stack. See Flow Control section.         |
| OP\_VERIF     | 101    | 0x65 | comparison value            | (conditional execution) | Compares using greater-than-or-equal with transaction version. See Flow Control section.     |
| OP\_VERNOTIF  | 102    | 0x66 | comparison value            | (conditional execution) | Negated version comparison. See Flow Control section.                                        |
| OP\_LSHIFTNUM | 182    | 0xb6 | a b                         | out                     | Arithmetic left shift of value a by b bits. Preserves the sign bit. See Arithmetic section.  |
| OP\_RSHIFTNUM | 183    | 0xb7 | a b                         | out                     | Arithmetic right shift of value a by b bits. Preserves the sign bit. See Arithmetic section. |
| OP\_SUBSTR    | 179    | 0xb3 | string, start index, length | substring               | Returns substring. See String Operations section.                                            |
| OP\_LEFT      | 180    | 0xb4 | string, length              | substring               | Returns leftmost characters. See String Operations section.                                  |
| OP\_RIGHT     | 181    | 0xb5 | string, length              | substring               | Returns rightmost characters. See String Operations section.                                 |

## 11. Pseudo-words

These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.

| Word              | Opcode | Hex  | Description                                           |
| ----------------- | ------ | ---- | ----------------------------------------------------- |
| OP\_PUBKEYHASH    | 253    | 0xfd | Represents a public key hashed with OP\_HASH160.      |
| OP\_PUBKEY        | 254    | 0xfe | Represents a public key compatible with OP\_CHECKSIG. |
| OP\_INVALIDOPCODE | 255    | 0xff | Matches any opcode that is not yet assigned.          |

## 12. Reserved words

Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction **invalid**.

| Word                         | Opcode       | Hex             | When used...                                                                                                            |
| ---------------------------- | ------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------- |
| OP\_RESERVED                 | 80           | 0x50            | Transaction is invalid unless occuring in an unexecuted OP\_IF branch                                                   |
| OP\_RESERVED1                | 137          | 0x89            | Transaction is invalid unless occuring in an unexecuted OP\_IF branch                                                   |
| OP\_RESERVED2                | 138          | 0x8a            | Transaction is invalid unless occuring in an unexecuted OP\_IF branch                                                   |
| OP\_NOP1, OP\_NOP4-OP\_NOP10 | 176, 184-185 | 0xb0, 0xb8-0xb9 | The word is ignored. Does not mark transaction as invalid. Note: 0xb6 and 0xb7 are now OP\_LSHIFTNUM and OP\_RSHIFTNUM. |

## Attribution

This content is based on content sourced from <https://en.bitcoin.it/wiki/Script> under [Creative Commons Attribution 3.0](https://creativecommons.org/licenses/by/3.0/). Although it may have been extensively revised and updated we acknowledge the original authors.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hub.bsvblockchain.org/wiki/bitcoin-script-and-opcodes/script/opcodes-used-in-bitcoin-script.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
