diff --git a/ligo/id_strings.ligo b/ligo/id_strings.ligo new file mode 100644 index 0000000..448d21c --- /dev/null +++ b/ligo/id_strings.ligo @@ -0,0 +1,7 @@ +type storage = unit + +let%entry main + (_parameter : string) + storage = + ( [], storage ) + diff --git a/ligo/send_one_tez.ligo b/ligo/send_one_tez.ligo new file mode 100644 index 0000000..d7c9e16 --- /dev/null +++ b/ligo/send_one_tez.ligo @@ -0,0 +1,12 @@ +(* A contract that sends 1 tez to anyone who asks. *) + +type storage = unit + +(* Initialize storage to (). *) +let%init storage = () + +let%entry main + (key : key_hash) + _storage = + let op = Account.transfer ~dest:key ~amount:1tz in + ( [op], () ) \ No newline at end of file diff --git a/liquidity/examples/data_publisher/data_publisher_hash.liq b/liquidity/examples/data_publisher/data_publisher_hash.liq new file mode 100644 index 0000000..a8a8b81 --- /dev/null +++ b/liquidity/examples/data_publisher/data_publisher_hash.liq @@ -0,0 +1,17 @@ +(* A contract that publishes data securely. *) + +type storage = { + publisher : address; + data : bytes +} + +let%entry main (param : string) storage = + if (Crypto.sha512 (Bytes.pack param)) = storage.data then + if Current.amount() < 1tz then + failwith "Not enough money, queries cost 1 tez." + else + ([], storage) + else if Current.sender () <> storage.publisher then + failwith "Cannot authenticate." + else + ([], storage.data <- Crypto.sha512 (Bytes.pack param)) \ No newline at end of file diff --git a/liquidity/examples/data_publisher/data_publisher_hash.tz b/liquidity/examples/data_publisher/data_publisher_hash.tz new file mode 100644 index 0000000..f1dfe59 --- /dev/null +++ b/liquidity/examples/data_publisher/data_publisher_hash.tz @@ -0,0 +1,34 @@ +parameter string; +storage (pair :storage (address %publisher) (bytes %data)); +code { DUP ; + DIP { CDR @storage_slash_1 } ; + CAR @param_slash_2 ; + DUUP @storage ; + CDR %data ; + DUUP @param ; + PACK ; + SHA512 ; + COMPARE ; + EQ ; + IF { PUSH mutez 1000000 ; + AMOUNT ; + COMPARE ; + LT ; + IF { PUSH string "Not enough money, queries cost 1 tez." ; FAILWITH } + { DUUP @storage ; NIL operation ; PAIR } } + { DUUP @storage ; + CAR %publisher ; + SENDER ; + COMPARE ; + NEQ ; + IF { PUSH string "Cannot authenticate." ; FAILWITH } + { DUUP @storage ; + CAR %publisher ; + DUUP @param ; + PACK ; + SHA512 ; + SWAP ; + PAIR %publisher %data ; + NIL operation ; + PAIR } } ; + DIP { DROP ; DROP } };