A friendly Smart Contract Language for Tezos
Smart contracts were never so easy
- JsLIGO
- CameLIGO
type storage = int;type parameter =| ["Increment", int]| ["Decrement", int]| ["Reset"];/* Two entrypoints */const add = (store: storage, delta: int) => store + delta;const sub = (store: storage, delta: int) => store - delta;/* Main access point that dispatches to the entrypoints according tothe smart contract parameter. */const main = (action: parameter, store: storage) : [ list<operation> , storage ] => {return [list([]), // No operations(match (action, {Increment: n => add (store, n),Decrement: n => sub (store, n),Reset: () => 0}))]};/* Tests for main access point */const test_initial_storage = (() => {let initial_storage = 42;let [taddr, _, _] = Test.originate(main, initial_storage, 0 as tez);return assert(Test.get_storage(taddr) == initial_storage)}) ();const test_increment = (() => {let initial_storage = 42;let [taddr, _, _] = Test.originate(main, initial_storage, 0 as tez);let contr = Test.to_contract(taddr);let _ = Test.transfer_to_contract_exn(contr, (Increment (1)), 1 as mutez);return assert(Test.get_storage(taddr) == initial_storage + 1);}) ();
type storage = inttype parameter =Increment of int| Decrement of int| Reset// Two entrypointslet add (store : storage) (delta : int) = store + deltalet sub (store : storage) (delta : int) = store - delta(* Main access point that dispatches to the entrypoints according tothe smart contract parameter. *)let main (action : parameter) (store : storage) : operation list * storage =[], // No operations(match action withIncrement (n) -> add store n| Decrement (n) -> sub store n| Reset -> 0)(* Tests for main access point *)let initial_storage = 42let test_initial_storage =let (taddr, _, _) = Test.originate main initial_storage 0tez inassert (Test.get_storage taddr = initial_storage)let test_increment =let (taddr, _, _) = Test.originate main initial_storage 0tez inlet contr = Test.to_contract taddr inlet _ = Test.transfer_to_contract_exn contr (Increment 1) 1mutez inassert (Test.get_storage taddr = initial_storage + 1)
Strong, Static Type System
Write types, then code. Benefit from the safety of type systems.
Polyglot
Code in your language. Write in CameLIGO, JsLIGO or add your own syntax.
Easy Integration
You can use LIGO as a Node.js library with Truffle.