Commit 4cd89732 authored by J H's avatar J H

Merge branch 'first-tutorial-update-data-types' into 'master'

First tutorial update data types

See merge request !12
parents 9b8e9d74 c6ca26e3
......@@ -121,9 +121,10 @@ in the same directory you put the `alphanet.sh` script.
# helloTezos.tz
parameter unit;
storage string;
code {DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;};
code { DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;
};
```
First we're going to check that the script is well-typed:
......@@ -205,9 +206,10 @@ Let's take another look at `helloTezos.tz`:
# helloTezos.tz
parameter unit;
storage string;
code {DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;};
code { DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;
};
```
The `parameter unit` and `storage string` lines specify the types of the
......@@ -276,9 +278,10 @@ the `code` heading in `helloTezos.tz`:
```
# helloTezos.tz
code {DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;};
code { DROP;
PUSH string "Hello Tezos!";
NIL operation; PAIR;
};
```
If we write down this operation sequence and the initial values and types from
......@@ -460,7 +463,8 @@ constructors.
type :: 'b : 'A -> 'b : 'C
iff ops :: [ 'A -> 'C ]
```
`ops` can be empty `{}` or a list of operations like `{PUSH string "Hello"; CONCAT}`
You could also use `SWAP` instead of `DIP`
```
SWAP # Exchange the top two elements of the stack.
......@@ -473,30 +477,45 @@ constructors.
Outer single quotes only required for passing literals through the command line.
(adapted from `https://www.michelson-lang.com/contract-a-day.html`)
| Type | Data |
|--------------------------|-------------------------------------------------------------|
| `unit` | `Unit` |
| `nat` | `12312321` |
| `int` | `12312321` |
| `int` | `'(-12223)'` |
| `string` | `'"hello"'` |
| `string` | `"\"hello\""` |
| `bool` | `True` |
| `bool` | `False` |
| `timestamp` | `10000` |
| `timestamp` | `'"2017-08-14T18:00:21Z"'` |
| `tez` | `'"100.00"'` |
| `(lambda unit unit)` | `{}` |
| `(lambda string string)` | `{PUSH string "hello"; CONCAT}` |
| `bytes` | `0x0001` |
| `key` | `"edpktieBMrR9Df3dqzZAJpDZBXb1h188fyrQyRJcm5RH2WpbvMVR8b"'` |
| `signature` | `"edsigtrs8bK7vNfiR4Kd9dWasVa1bAWaQSu2ipnmLGZuwQa8ktCEMYVKqbWsbJ7zTS8dgYT9tiSUKorWCPFHosL5zPsiDwBQ6vb"` |
| `key_hash` | `"tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU"'` |
| `(contract unit unit)` | `"tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU"'` |
| `(map nat bool)` | `(Map (Item 100 False) (Item 90 True))'` |
| `(set nat)` | `(Set 1 2 3 4')` |
| `(list int)` | `(List 1 -123 12312)` |
| `(option bool)` | `(Some False)` |
| `(option bool)` | `None` |
| `(or nat bool)` | `'(Left 100)'` |
| `(or nat bool)` | `'(Right False)'` |
| Type | Data |
|--------------------------|---------------------------------------------|
| `unit` | `Unit` |
| `nat` | `12312321` |
| `int` | `12312321` |
| `int` | `-12223` |
| `string` | `'"hello"'` |
| `bool` | `True` |
| `bool` | `False` |
| `timestamp` | `10000` |
| `timestamp` | `'"2017-08-14T18:00:21Z"'` |
| `mutez` | `1` (equivalent to 1/1000000 of a tez) |
| `mutez` | `10000` (equivalent to one tez cent) |
| `mutez` | `1000000` (equivalent to one tez) |
| `(lambda unit unit)` | `{}` |
| `(lambda string string)` | `{PUSH string "hello"; CONCAT}` |
| `bytes` | `0x0001` |
| `key` | `'"edpktieBMrR9Df3dqzZAJpDZBXb1h188fyrQyRJcm5RH2WpbvMVR8b"'` |
| `signature` | `'"edsigtrs8bK7vNfiR4Kd9dWasVa1bAWaQSu2ipnmLGZuwQa8ktCEMYVKqbWsbJ7zTS8dgYT9tiSUKorWCPFHosL5zPsiDwBQ6vb"'` |
| `key_hash` | `'"tz1Z1nn9Y7vzyvtf6rAYMPhPNGqMJXw88xGH"'` |
| `address` | `'"tz1Z1nn9Y7vzyvtf6rAYMPhPNGqMJXw88xGH"'` |
| `(contract unit)` | `'"tz1Z1nn9Y7vzyvtf6rAYMPhPNGqMJXw88xGH"'` (not a smart contract) |
| `(contract unit)` | `'"KT1EM8rZNSvjRny1tqQWp4qWd6uTA9FeSFvU "'` (a smart contract) |
| `(big_map nat bool)` | `{}` (an empty big_map) |
| `(big_map nat bool)` | `{Elt 1 False}` (a big_map with one element) |
| `(big_map nat bool)` | `{Elt 1 False; Elt 1 True}` (a big_map with two elements) |
| `(map nat bool)` | `{}` (an empty map) |
| `(map nat bool)` | `{Elt 1 False}` (a map with one element) |
| `(map nat bool)` | `{Elt 1 False; Elt 1 True}` (a map with two elements) |
| `(set nat)` | `{}` (an empty set) |
| `(set nat)` | `{1; 2; 3; 4}` |
| `(list int)` | `{}` (an empty list) |
| `(list int)` | `{1; -123; 12312}` |
| `(option bool)` | `(Some False)` |
| `(option bool)` | `None` |
| `(or nat bool)` | `(Left 100)` |
| `(or nat bool)` | `(Right False)` |
| `(or (or nat unit) (or bool string))` | `(Left (Left 2))` |
| `(or (or nat unit) (or bool string))` | `(Left (Right Unit))` |
| `(or (or nat unit) (or bool string))` | `(Right (Left True))` |
| `(or (or nat unit) (or bool string))` | `(Right (Right "hello"))` |
| `(pair nat bool)` | `(Pair 1 True)` |
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment