Passer au contenu

Bitcoin accepté au paiement  |  Expédié depuis Montréal, QC, Canada  |  Soutien expert depuis 2016

Opcodes de Bitcoin Script

Bitcoin Script est un petit langage à pile non-Turing-complet. Cette référence liste tous les opcodes — mot, octet hex, décimal, catégorie, statut et fonction — y compris ceux désactivés et les no-ops évolutifs qui permettent les soft forks. Les mots d’opcode et valeurs restent en anglais, source unique.

Réponse rapide

Bitcoin Script est un petit langage à pile, intentionnellement non-Turing-complet : un script de verrouillage (scriptPubKey) fixe les conditions de dépense et un script de déverrouillage (scriptSig / witness) les satisfait. Cette référence liste les 113 opcodes — mot, octet hex, décimal, catégorie, statut et fonction. 15 sont désactivés (retirés en 2010 pour la sécurité), plusieurs emplacements sont réservés, et les no-ops évolutifs (OP_NOP1–NOP10) sont la façon dont des soft forks comme CLTV et CSV ont ajouté de nouvelles règles sans casser les anciens nœuds.

La plupart des scripts courants utilisent une poignée d'opcodes — OP_DUP, OP_HASH160, OP_EQUALVERIFY et OP_CHECKSIG construisent le P2PKH ; OP_CHECKMULTISIG, OP_CHECKLOCKTIMEVERIFY et OP_CHECKSEQUENCEVERIFY permettent le multisig et les verrous temporels ; Tapscript ajoute OP_CHECKSIGADD.

Télécharger le CSV Télécharger le JSON API REST →

MotHexDécCatégorieStatutBIPFonction
OP_0 / OP_FALSE0x000ConstantsEnabledPush an empty byte array (numeric/boolean zero) onto the stack.
OP_PUSHBYTES_1–750x01–0x4b1ConstantsEnabledThe next opcode byte (1–75) is the number of subsequent bytes to push as data.
OP_PUSHDATA10x4c76ConstantsEnabledThe next 1 byte is the length; push that many following bytes.
OP_PUSHDATA20x4d77ConstantsEnabledThe next 2 bytes (LE) are the length; push that many following bytes.
OP_PUSHDATA40x4e78ConstantsEnabledThe next 4 bytes (LE) are the length; push that many following bytes.
OP_1NEGATE0x4f79ConstantsEnabledPush the number -1 onto the stack.
OP_RESERVED0x5080ReservedReservedInvalidates the script if executed (does nothing inside an unexecuted branch).
OP_1 / OP_TRUE0x5181ConstantsEnabledPush the number 1 onto the stack.
OP_20x5282ConstantsEnabledPush the number 2 onto the stack.
OP_30x5383ConstantsEnabledPush the number 3 onto the stack.
OP_40x5484ConstantsEnabledPush the number 4 onto the stack.
OP_50x5585ConstantsEnabledPush the number 5 onto the stack.
OP_60x5686ConstantsEnabledPush the number 6 onto the stack.
OP_70x5787ConstantsEnabledPush the number 7 onto the stack.
OP_80x5888ConstantsEnabledPush the number 8 onto the stack.
OP_90x5989ConstantsEnabledPush the number 9 onto the stack.
OP_100x5a90ConstantsEnabledPush the number 10 onto the stack.
OP_110x5b91ConstantsEnabledPush the number 11 onto the stack.
OP_120x5c92ConstantsEnabledPush the number 12 onto the stack.
OP_130x5d93ConstantsEnabledPush the number 13 onto the stack.
OP_140x5e94ConstantsEnabledPush the number 14 onto the stack.
OP_150x5f95ConstantsEnabledPush the number 15 onto the stack.
OP_160x6096ConstantsEnabledPush the number 16 onto the stack.
OP_NOP0x6197Flow controlEnabledDoes nothing.
OP_VER0x6298ReservedReservedInvalidates the script if executed.
OP_IF0x6399Flow controlEnabledExecute the following statements if the top stack value is true.
OP_NOTIF0x64100Flow controlEnabledExecute the following statements if the top stack value is false.
OP_VERIF0x65101ReservedReservedInvalidates the script even when inside an unexecuted branch.
OP_VERNOTIF0x66102ReservedReservedInvalidates the script even when inside an unexecuted branch.
OP_ELSE0x67103Flow controlEnabledSwitch execution within an OP_IF / OP_NOTIF … OP_ENDIF block.
OP_ENDIF0x68104Flow controlEnabledClose an OP_IF / OP_NOTIF / OP_ELSE block.
OP_VERIFY0x69105Flow controlEnabledMark the script invalid unless the top stack value is true; otherwise pop it.
OP_RETURN0x6a106Flow controlEnabledMark the output provably unspendable; commonly used to embed up to 80 bytes of data.
OP_TOALTSTACK0x6b107StackEnabledMove the top item to the alt stack.
OP_FROMALTSTACK0x6c108StackEnabledMove the top alt-stack item back to the main stack.
OP_2DROP0x6d109StackEnabledRemove the top two stack items.
OP_2DUP0x6e110StackEnabledDuplicate the top two stack items.
OP_3DUP0x6f111StackEnabledDuplicate the top three stack items.
OP_2OVER0x70112StackEnabledCopy the pair of items two spaces back to the top.
OP_2ROT0x71113StackEnabledMove the fifth and sixth items to the top.
OP_2SWAP0x72114StackEnabledSwap the top two pairs of items.
OP_IFDUP0x73115StackEnabledDuplicate the top item only if it is non-zero.
OP_DEPTH0x74116StackEnabledPush the current number of stack items.
OP_DROP0x75117StackEnabledRemove the top stack item.
OP_DUP0x76118StackEnabledDuplicate the top stack item (core of P2PKH).
OP_NIP0x77119StackEnabledRemove the second-from-top item.
OP_OVER0x78120StackEnabledCopy the second-from-top item to the top.
OP_PICK0x79121StackEnabledCopy the n-th item (n from the top) to the top.
OP_ROLL0x7a122StackEnabledMove the n-th item (n from the top) to the top.
OP_ROT0x7b123StackEnabledRotate the top three items.
OP_SWAP0x7c124StackEnabledSwap the top two items.
OP_TUCK0x7d125StackEnabledCopy the top item and insert it below the second item.
OP_CAT0x7e126SpliceDisabledConcatenate two byte strings. Disabled for security in 2010.
OP_SUBSTR0x7f127SpliceDisabledReturn a substring. Disabled.
OP_LEFT0x80128SpliceDisabledReturn the left substring. Disabled.
OP_RIGHT0x81129SpliceDisabledReturn the right substring. Disabled.
OP_SIZE0x82130SpliceEnabledPush the byte length of the top item (without popping it).
OP_INVERT0x83131Bitwise logicDisabledBitwise NOT. Disabled.
OP_AND0x84132Bitwise logicDisabledBitwise AND. Disabled.
OP_OR0x85133Bitwise logicDisabledBitwise OR. Disabled.
OP_XOR0x86134Bitwise logicDisabledBitwise XOR. Disabled.
OP_EQUAL0x87135Bitwise logicEnabledPush 1 if the top two items are byte-equal, else 0 (core of P2SH).
OP_EQUALVERIFY0x88136Bitwise logicEnabledOP_EQUAL then OP_VERIFY — fail unless the top two items are equal.
OP_RESERVED10x89137ReservedReservedInvalidates the script if executed.
OP_RESERVED20x8a138ReservedReservedInvalidates the script if executed.
OP_1ADD0x8b139ArithmeticEnabledAdd 1 to the top number.
OP_1SUB0x8c140ArithmeticEnabledSubtract 1 from the top number.
OP_2MUL0x8d141ArithmeticDisabledMultiply the top number by 2. Disabled.
OP_2DIV0x8e142ArithmeticDisabledDivide the top number by 2. Disabled.
OP_NEGATE0x8f143ArithmeticEnabledFlip the sign of the top number.
OP_ABS0x90144ArithmeticEnabledAbsolute value of the top number.
OP_NOT0x91145ArithmeticEnabledPush 1 if the top number is 0, else 0.
OP_0NOTEQUAL0x92146ArithmeticEnabledPush 0 if the top number is 0, else 1.
OP_ADD0x93147ArithmeticEnabledAdd the top two numbers.
OP_SUB0x94148ArithmeticEnabledSubtract the top number from the second.
OP_MUL0x95149ArithmeticDisabledMultiply the top two numbers. Disabled.
OP_DIV0x96150ArithmeticDisabledDivide. Disabled.
OP_MOD0x97151ArithmeticDisabledModulo. Disabled.
OP_LSHIFT0x98152ArithmeticDisabledLeft bit-shift. Disabled.
OP_RSHIFT0x99153ArithmeticDisabledRight bit-shift. Disabled.
OP_BOOLAND0x9a154ArithmeticEnabledPush 1 if both numbers are non-zero, else 0.
OP_BOOLOR0x9b155ArithmeticEnabledPush 1 if either number is non-zero, else 0.
OP_NUMEQUAL0x9c156ArithmeticEnabledPush 1 if the two numbers are equal, else 0.
OP_NUMEQUALVERIFY0x9d157ArithmeticEnabledOP_NUMEQUAL then OP_VERIFY.
OP_NUMNOTEQUAL0x9e158ArithmeticEnabledPush 1 if the two numbers are not equal, else 0.
OP_LESSTHAN0x9f159ArithmeticEnabledPush 1 if the second number is less than the top.
OP_GREATERTHAN0xa0160ArithmeticEnabledPush 1 if the second number is greater than the top.
OP_LESSTHANOREQUAL0xa1161ArithmeticEnabledPush 1 if the second number is ≤ the top.
OP_GREATERTHANOREQUAL0xa2162ArithmeticEnabledPush 1 if the second number is ≥ the top.
OP_MIN0xa3163ArithmeticEnabledPush the smaller of the top two numbers.
OP_MAX0xa4164ArithmeticEnabledPush the larger of the top two numbers.
OP_WITHIN0xa5165ArithmeticEnabledPush 1 if x is within [min, max).
OP_RIPEMD1600xa6166CryptographyEnabledHash the top item with RIPEMD-160.
OP_SHA10xa7167CryptographyEnabledHash the top item with SHA-1.
OP_SHA2560xa8168CryptographyEnabledHash the top item with SHA-256.
OP_HASH1600xa9169CryptographyEnabledSHA-256 then RIPEMD-160 (address hashing).
OP_HASH2560xaa170CryptographyEnabledDouble SHA-256 of the top item.
OP_CODESEPARATOR0xab171CryptographyEnabledMark the point from which signature checks cover the script.
OP_CHECKSIG0xac172CryptographyEnabledVerify a signature against a public key over the transaction.
OP_CHECKSIGVERIFY0xad173CryptographyEnabledOP_CHECKSIG then OP_VERIFY.
OP_CHECKMULTISIG0xae174CryptographyEnabledVerify m-of-n signatures (consumes one extra item — the off-by-one bug).
OP_CHECKMULTISIGVERIFY0xaf175CryptographyEnabledOP_CHECKMULTISIG then OP_VERIFY.
OP_NOP10xb0176Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_CHECKLOCKTIMEVERIFY (OP_NOP2)0xb1177LocktimeEnabledBIP65Fail unless the output is spent at or after an absolute time/height (CLTV).
OP_CHECKSEQUENCEVERIFY (OP_NOP3)0xb2178LocktimeEnabledBIP112Fail unless a relative lock-time has elapsed (CSV).
OP_NOP40xb3179Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP50xb4180Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP60xb5181Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP70xb6182Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP80xb7183Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP90xb8184Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_NOP100xb9185Reserved (NOP)ReservedUpgradeable no-op reserved for a future soft fork.
OP_CHECKSIGADD0xba186CryptographyTapscriptBIP342Tapscript-only: verify a signature and add 1 to an accumulator (batch multisig).

Source : Bitcoin Core script/script.h (enum opcodetype) et la référence Bitcoin Wiki Script. Connexe : registre des soft forks, index des BIP, tailles de transaction, types d'adresse. Voir le carrefour de données ouvertes.

La plupart des scripts courants utilisent une poignée d’opcodes. Ce jeu de données ouvert (CC BY 4.0) fait partie du catalogue de données ouvertes de D-Central.