OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

Programming Bitcoin Script Transaction Contracts

An educational Ruby project that explains Bitcoin Script by building a simple stack machine and walking through operations, opcodes, and transaction-script examples.

Independent OpenViST project profile, based on linked sources.

Programming Bitcoin Script Transaction Contracts — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when studying Bitcoin Script fundamentals through small code examples and transaction-script puzzles.

Who it is for

  • Developers learning the stack-based mechanics of Bitcoin Script.
  • Readers studying how unlocking and locking transaction scripts combine.

Documented uses

  • Trace how simple operations push, pop, and transform stack values.
  • Relate Ruby examples to Bitcoin Script notation and opcodes.
  • Work through a transaction-script puzzle involving an unlocking input and a locking output.
Before you choose

Requirements & limits

The repository is public and identifies its license as CC0-1.0.

  • Examples are written in Ruby and focus on a simple stack machine.
  • The material explains concepts and examples; it does not establish a packaged library, API, or interactive interface.
  • The repository describes Bitcoin Script as left-to-right and without loops.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Build a minimal Ruby stack machine for Bitcoin Script operations

Model OP_2 and OP_ADD to compute 2 + 2 on a stack.

Before you start

  • Ruby, as used by the documented example.
  • A stack supporting push and pop operations.

Steps

  1. Initialize an empty stack.

  2. Define op_2 to push the number 2 onto the stack.

  3. Define op_add to pop the top two values, add them, and push the result.

  4. Call op_2 twice, then op_add; inspect the stack result.

Expected outcome

The stack contains [4] after the two pushes and addition.

Guide limitations

  • This is a minimal educational stack-machine example, not a packaged library or a documented Bitcoin transaction execution interface.
  • The example covers only the two operations shown.
Source-based practical guide

Work through the two-part ? + 2 = 4 stack puzzle

Represent an unlock value and a lock-side script that checks whether adding 2 produces 4.

Before you start

  • Ruby stack operations using push and pop.
  • Definitions for op_2, op_add, op_4, and op_equal, as shown in the example.

Steps

  1. Initialize an empty stack.

  2. In the ScriptSig (input/unlock) part, push the missing value onto the stack.

  3. In the ScriptPubKey (output/lock) part, run op_2, op_add, op_4, and op_equal in that order.

  4. Inspect the final stack value; the example describes 1 as true.

Expected outcome

For the puzzle value 2, the operations leave [1] on the stack.

Guide limitations

  • The puzzle is an educational stack-machine illustration; it does not document a complete transaction, network interaction, or production validation procedure.
  • Bitcoin Script is described as stack-based and intentionally not Turing-complete, with no loops.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
17 October 2026
Original website title
openblockchains/programming-bitcoin-script · Official homepage title · retained in its source language