Michelson - test simulator / runtime for type-safe 'n' functional (crypto) contracts

michelson gem / library - test simulator / runtime for type-safe 'n' functional (crypto) contracts

Usage

What's Michelson? What's Liquidity?

The Liquidity language lets you programm (crypto) contracts with (higher-level type-safe functional) OCaml or ReasonML syntax compiling to (lower-level) Michelson stack machine bytecode.

Using the michelson test simulator / runtime for type-safe 'n' functional (crypto) contracts you can now use a "Yes, It's Just Ruby" syntax.

By Example

Let's Count - 0, 1, 2, 3

type :Storage, Integer

init [],
def storage()
  0
end

entry [Integer],
def inc( by, storage )
  [[], storage + by]
end

And for (local) testing you can run the "Yes, It's Just Ruby" version with the michelson testnet "simulator" library. Try:

storage  = storage()
# => calling storage()...
# => returning:
# => 0
_, storage = inc( 2, storage )
# => calling inc( 2, 0 )...
# => returning:
# => [[], 2]
_, storage = inc( 1, storage )
# => calling inc( 1, 2 )...
# => returning:
# => [[], 3]

Let's Vote

type :Storage, Map

And again for (local) testing you can run the "Yes, It's Just Ruby" version with the michelson testnet "simulator" library. Try:

storage  = storage()
#=> calling storage()...
#=> returning:
#=> {"ocaml"=>0, "reason"=>0, "ruby"=>0}
_, storage = vote( "ruby", storage )
#=> calling vote( "ruby", {"ocaml"=>0, "reason"=>0, "ruby"=>0} )...
#=> !! RuntimeError: failwith - Not enough money, at least 5tz to vote

Current.amount = 10.tz

_, storage = vote( "ruby", storage )
#=> calling vote( "ruby", {"ocaml"=>0, "reason"=>0, "ruby"=>0} )...
#=> returning:
#=> [[], {"ocaml"=>0, "reason"=>0, "ruby"=>1}]
_, storage = vote( "reason", storage )
#=> calling vote( "reason", {"ocaml"=>0, "reason"=>0, "ruby"=>1} )...
#=> returning:
#=> [[], {"ocaml"=>0, "reason"=>1, "ruby"=>1}]
_, storage = vote( "python", storage )
#=> calling vote( "python", {"ocaml"=>0, "reason"=>1, "ruby"=>1} )...
#=> !! RuntimeError: failwith - Bad vote

And so on and so forth.

License

The michelson scripts are dedicated to the public domain. Use it as you please with no restrictions whatsoever.

Questions? Comments?

Send them along to the wwwmake forum. Thanks!