Opcodes (operation codes) are an essential part of Bitcoin’s scripting language, Script, enabling operations on the Bitcoin network.  

Read on to learn what opcodes are, what they do, and what types of opcodes are currently operational.

What Are Opcodes?

Opcodes (operational codes) are instructions that allow setting transaction conditions on the Bitcoin protocol, with each opcode designed to execute a specific command on the network. 

Bitcoin users and developers can utilize opcodes to remove, add, move, or rotate elements on the stack, invalidate or validate transactions, execute calculations, and perform other functions. The opcodes serve as tools to ensure network transactions function seamlessly. 

Bitcoin’s programming language, Bitcoin Script, allows people to utilize opcodes to perform different operations. Bitcoin Script is a simple programming language designed to limit its functionality and prevent instances of error execution and endless looping. The design helps ensure complicated operations cannot slow the network down.  

Opcodes are the foundation of Bitcoin’s scripting capabilities that enable automated, customizable transactions. Users can input the code as a word command with the “OP” prefix.

As a digital currency, Bitcoin is programmable money, and using opcodes, you can program various commands. Bitcoin’s structure allows users to define up to 256 opcodes, with the opcodes assigned a number between 0 and 255. Currently, less than half of them are active.

What Do Opcodes Do in Bitcoin?

On the Bitcoin network, opcodes play a central role in defining the formulation and execution of transactions. Users need transactions to take various forms. Opcodes help ensure seamless operations regardless of the complexity of the conditions and rules of each transaction.

Bitcoin Script allows users to write programs that execute commands. Script opcodes are the users’ way of communicating to indicate the functions they wish to implement. The opcodes include instructions on the access and utilization of the bitcoins involved in that transaction. 

The OP_CAT Bitcoin opcode would be an example of what opcodes do in Bitcoin. In 2010, it became inactive due to the community’s concerns about memory-related issues. Over time, alleviation of those concerns led to OP_CAT’s recent re-emergence. 

When it comes to OP_CAT, the opcode can potentially implement covenants that spell out conditions for issuing Bitcoin outputs. This introduces scalable, controlled transactions. Additionally, the opcode plays a role in optimizing and simplifying the Bitcoin Virtual Machine (BitVM). An efficient and user-friendly BitVM raises Bitcoin’s profile as a platform for innovation

Types of Opcodes in Bitcoin

Opcodes fall into various categories based on their functions. Let’s look at the existing types of opcodes in Bitcoin. 

  • Cryptography: Users can utilize such opcodes to execute cryptographic commands on the target data. An example is OP_HASH256, which hashes the input twice using SHA-256, a cryptographic algorithm that improves security. 
  • Flow control: When you need an opcode to determine the script’s flow, those in this category come in handy. An example is OP_VERIFY, which marks a transaction as invalid if the top stack is false. 
  • Constants: With this category of opcodes, you can push a specific amount of data to the stack. An example is OP_1NEGATE, which executes a command to push the number -1 onto the stack. 
  • Stack: Users deploy this opcode type to move items on the stack as they wish. An example is OP_2DROP, which removes the top two stack items. 
  • Bitwise logic: This group of opcodes comes in handy when you need a command that activates based on specified input data. An example is OP_INVERT, which flips all of the bits in an input. 
  • Data manipulation: With these opcodes, you can specify the manipulation parameters for the provided data. An example is OP_NUM2BIN, which converts a numeric value into a byte sequence of a predetermined length. 
  • Arithmetic: You can execute mathematical operations using the group of opcodes. An example is OP_MUL, which performs a multiplication operation. 


Bitcoin opcodes shape the network’s functionality and provide avenues for the ecosystem’s evolution. Opcodes’ versatility presents a pathway towards improving the Bitcoin network’s adaptability and encouraging innovation, thus playing an essential role in the future of Bitcoin.