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

HexDecNameDescription
0x000OP_0 / OP_FALSEPush empty byte array (falsy)
0x010x4b1–75(data push)Push next \(N\) bytes onto stack
0x4c76OP_PUSHDATA1Next byte = length; push that many bytes
0x4d77OP_PUSHDATA2Next 2 bytes (LE) = length; push
0x4e78OP_PUSHDATA4Next 4 bytes (LE) = length; push
0x4f79OP_1NEGATEPush \(-1\)
0x5080OP_RESERVEDReserved; fails if executed
0x510x6081–96OP_1OP_16Push value 1–16

A.2Flow Control

HexDecNameDescription
0x6197OP_NOPDoes nothing
0x6298OP_VERReserved; fails if executed
0x6399OP_IFExecute next block if top is truthy
0x64100OP_NOTIFExecute next block if top is falsy
0x65101OP_VERIFDisabled — always fails
0x66102OP_VERNOTIFDisabled — always fails
0x67103OP_ELSEExecute if preceding IF/NOTIF was false
0x68104OP_ENDIFEnd conditional block
0x69105OP_VERIFYFail if top is falsy; otherwise pop
0x6a106OP_RETURNMark output as provably unspendable

A.3Stack Operations

HexDecNameDescription
0x6b107OP_TOALTSTACKMove top item to alt stack
0x6c108OP_FROMALTSTACKMove top of alt stack to main stack
0x6d109OP_2DROPRemove top 2 items
0x6e110OP_2DUPDuplicate top 2 items
0x6f111OP_3DUPDuplicate top 3 items
0x70112OP_2OVERCopy items 3–4 to top
0x71113OP_2ROTMove items 5–6 to top
0x72114OP_2SWAPSwap top two pairs
0x73115OP_IFDUPDuplicate top if truthy
0x74116OP_DEPTHPush stack depth
0x75117OP_DROPRemove top item
0x76118OP_DUPDuplicate top item
0x77119OP_NIPRemove second item
0x78120OP_OVERCopy second item to top
0x79121OP_PICKCopy \(n\)th item to top
0x7a122OP_ROLLMove \(n\)th item to top
0x7b123OP_ROTRotate top 3 items
0x7c124OP_SWAPSwap top 2 items
0x7d125OP_TUCKCopy top behind second

A.4Splice Operations

HexDecNameDescription
0x7e126OP_CATDisabled — concatenate two strings
0x7f127OP_SUBSTRDisabled — return substring
0x80128OP_LEFTDisabled — keep left \(n\) bytes
0x81129OP_RIGHTDisabled — keep right \(n\) bytes
0x82130OP_SIZEPush byte length of top item (without popping)

A.5Bitwise Logic

HexDecNameDescription
0x83131OP_INVERTDisabled — flip all bits
0x84132OP_ANDDisabled — bitwise AND
0x85133OP_ORDisabled — bitwise OR
0x86134OP_XORDisabled — bitwise XOR
0x87135OP_EQUALPush 1 if top two are byte-identical
0x88136OP_EQUALVERIFYOP_EQUAL then OP_VERIFY
0x89137OP_RESERVED1Reserved; fails if executed
0x8a138OP_RESERVED2Reserved; 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.

HexDecNameDescription
0x8b139OP_1ADDAdd 1 to top
0x8c140OP_1SUBSubtract 1 from top
0x8d141OP_2MULDisabled — multiply by 2
0x8e142OP_2DIVDisabled — divide by 2
0x8f143OP_NEGATEFlip sign
0x90144OP_ABSAbsolute value
0x91145OP_NOTPush 1 if top is 0; else push 0
0x92146OP_0NOTEQUALPush 0 if top is 0; else push 1
0x93147OP_ADD\(a + b\)
0x94148OP_SUB\(a - b\)
0x95149OP_MULDisabled — \(a \times b\)
0x96150OP_DIVDisabled — \(a \div b\)
0x97151OP_MODDisabled — \(a \pmod{b}\)
0x98152OP_LSHIFTDisabled — left shift
0x99153OP_RSHIFTDisabled — right shift
0x9a154OP_BOOLANDPush 1 if both non-zero
0x9b155OP_BOOLORPush 1 if either non-zero
0x9c156OP_NUMEQUALPush 1 if numerically equal
0x9d157OP_NUMEQUALVERIFYNUMEQUAL then VERIFY
0x9e158OP_NUMNOTEQUALPush 1 if not equal
0x9f159OP_LESSTHANPush 1 if \(a < b\)
0xa0160OP_GREATERTHANPush 1 if \(a > b\)
0xa1161OP_LESSTHANOREQUALPush 1 if \(a \le b\)
0xa2162OP_GREATERTHANOREQUALPush 1 if \(a \ge b\)
0xa3163OP_MINPush lesser of two
0xa4164OP_MAXPush greater of two
0xa5165OP_WITHINPush 1 if \(\min \le x < \max\)

A.7Cryptographic Operations

HexDecNameDescription
0xa6166OP_RIPEMD160RIPEMD-160 hash of top item
0xa7167OP_SHA1SHA-1 hash of top item
0xa8168OP_SHA256SHA-256 hash of top item
0xa9169OP_HASH160SHA-256 then RIPEMD-160
0xaa170OP_HASH256Double SHA-256
0xab171OP_CODESEPARATORMark script position for signature hashing
0xac172OP_CHECKSIGVerify ECDSA/Schnorr signature
0xad173OP_CHECKSIGVERIFYCHECKSIG then VERIFY
0xae174OP_CHECKMULTISIGVerify \(m\)-of-\(n\) ECDSA signatures
0xaf175OP_CHECKMULTISIGVERIFYCHECKMULTISIG then VERIFY

A.8Locktime Operations

HexDecNameDescription
0xb0176OP_NOP1No-op (reserved for future soft forks)
0xb1177OP_CHECKLOCKTIMEVERIFYFail unless nLockTime top (BIP 65)
0xb2178OP_CHECKSEQUENCEVERIFYFail unless relative time elapsed (BIP 112)
0xb30xb9179–185OP_NOP4OP_NOP10No-ops (reserved for future soft forks)

A.9Tapscript Extensions (BIP 342)

These opcodes redefine behavior within Tapscript execution contexts only.

HexDecNameDescription
0xac172OP_CHECKSIGSchnorr signature verification (redefined)
0xad173OP_CHECKSIGVERIFYSchnorr verify + VERIFY (redefined)
0xba186OP_CHECKSIGADDSchnorr batch: increment counter if valid
0xae174OP_CHECKMULTISIGDisabled in Tapscript
0xaf175OP_CHECKMULTISIGVERIFYDisabled in Tapscript
0xbb0xfe187–254OP_SUCCESS187OP_SUCCESS254Success 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.

← Ch. 19 Next →