OP_RETURN Opcode Redefinition for Blockchain Script Looping

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The existing blockchain protocol's OP_RETURN opcode, used to terminate script execution and invalidate transactions, results in a loss of functionality due to its inability to enable in-script looping, as it prevents any transaction with OP_RETURN in its input script from achieving a valid execution when paired with an unlocking script.

Innovation Solution

Re-defining the OP_RETURN opcode to allow it to read a data element from the stack and output a part of the locking script following an OP_CODESEPARATOR (OCS) opcode, enabling in-script looping by jumping between script portions, rather than solely terminating execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If the OP_RETURN opcode is used to terminate script execution and invalidate transactions, then transaction validation is simplified, but script functionality is reduced due to inability to enable in-script looping

Engineering Contradiction:
Improvetransaction validationVSAvoidscript functionality
Core Design Contradiction:
Ease of operationVSAdaptability or versatility

Solution Approach 1:

The patent redefines OP_RETURN from a static termination opcode to a dynamic opcode that can either terminate execution or enable looping based on the context. When OP_RETURN encounters an OP_CODESEPARATOR on the stack, it pops the separator and continues execution, creating a loop. This dynamic behavior allows the same opcode to serve multiple functions depending on the runtime state.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent makes OP_RETURN a multi-functional opcode that can both terminate script execution (original function) and enable in-script looping (new function). By checking for OP_CODESEPARATOR on the stack, the opcode determines its behavior: if present, it creates a loop by continuing execution; if absent, it terminates execution. This universality resolves the contradiction between simplification and functionality.

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Reliability

If OP_RETURN is used to invalidate transactions, then double-spending prevention is achieved, but loss of functionality occurs due to inability to execute script parts conditionally or repeatedly

Engineering Contradiction:
Improvedouble-spending preventionVSAvoidconditional script execution
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent introduces dynamic looping capability through the interaction between OP_RETURN and OP_CODESEPARATOR. By pushing OP_CODESEPARATOR onto the stack before OP_RETURN and having OP_RETURN pop it to continue execution, the system creates conditional loops that allow script parts to be executed repeatedly or conditionally while maintaining transaction validity.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent uses OP_CODESEPARATOR to divide the locking script into separate segments or sections. OP_RETURN can selectively loop back to specific segments by popping OP_CODESEPARATOR markers, enabling conditional and repeated execution of specific script portions without invalidating the entire transaction. This segmentation allows fine-grained control over script execution flow.

Inventive Principle:
Principle #1Segmentation

3Quantity of substance

If the blockchain protocol allows complex data storage in transactions, then data capacity increases, but script execution complexity increases due to lack of looping constructs

Engineering Contradiction:
Improvedata capacityVSAvoidscript execution complexity
Core Design Contradiction:
Quantity of substanceVSDevice complexity

Solution Approach 1:

The patent implements self-service looping where the blockchain scripting language provides its own loop mechanism through the interaction of existing opcodes (OP_RETURN and OP_CODESEPARATOR) without requiring external or complex control structures. The script serves itself by using the stack to manage loop state, reducing the need for additional complex control flow instructions.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent uses OP_CODESEPARATOR as an intermediary marker that enables looping functionality. By placing OP_CODESEPARATOR at specific points in the script and having OP_RETURN pop and continue from those points, the system creates a mediation mechanism for control flow that works seamlessly with the existing opcode architecture, avoiding the need for complex dedicated loop constructs.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS12182541B2In-script functions within a blockchain transaction
Publication Date: 2024.12.31 NCHAIN LICENSING AG
  • US12182541B2 patent drawing
  • US12182541B2 patent drawing
  • US12182541B2 patent drawing

AI summary

A method of executing a transaction of a blockchain. The transaction comprises at least one output comprising a locking script, and the locking script comprises an instance of a first opcode and one or more instances of a second opcode. Each instance of the second opcode separates portions of the locking script. Upon calling the instance of the first opcode, a first data element is read from at least one stack, the first data element being generated during execution of the locking script with an unlocking script of a different transaction. A first part of the locking script that follows an instance of the second opcode corresponding to the first data element is output.