Programming Bitcoin Script Transaction (Crypto) Contracts Step-by-Step (in Ruby)

(Gerald Bauer) #1

Hello,

  I've started a new (free online) book(let) titled
  Programming Bitcoin Script Transaction (Crypto) Contracts
Step-by-Step (in Ruby) [1].

  Let's start with building your own bitcoin stack machine from zero /
scratch and let's run your own bitcoin ops (operations)...
  Example:

  ## A simple stack machine
  def op_add( stack )
    left = stack.pop
    right = stack.pop
    stack.push( left + right )
  end

  def op_2( stack )
    stack.push( 2 )
  end

  ## Let's run!

  stack = []
  op_2( stack ) #=> stack = [2]
  op_2( stack ) #=> stack = [2,2]
  op_add( stack ) #=> stack = [4]

  Unlock the ?+2=4 puzzle on your own computer and
  win "unspent transaction outputs" (UTXOs) on your own testnet.

   Happy bitcoin scripting with ruby.

[1] https://github.com/openblockchains/programming-bitcoin-script

0 Likes