1
0

sample.cameligo.txt 590 B

1234567891011121314151617
  1. type storage = int
  2. type parameter =
  3. Increment of int
  4. | Decrement of int
  5. | Reset
  6. type return = operation list * storage
  7. // Two entrypoints
  8. let add (store, delta : storage * int) : storage = store + delta
  9. let sub (store, delta : storage * int) : storage = store - delta
  10. (* Main access point that dispatches to the entrypoints according to
  11. the smart contract parameter. *)
  12. let main (action, store : parameter * storage) : return =
  13. ([] : operation list), // No operations
  14. (match action with
  15. Increment (n) -> add (store, n)
  16. | Decrement (n) -> sub (store, n)
  17. | Reset -> 0)