You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/cli/06_deploy.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,8 +119,8 @@ Saves the transaction to the directory located at the `<SAVE>` path.
119
119
#### `--skip <SUBSTRING_0> <SUBSTRING_1> ...`
120
120
Skips deployment of any program that contains one of the given substrings, delimited by a space.
121
121
122
-
#### `-y`
123
122
#### `--yes`
123
+
#### `-y`
124
124
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
125
125
126
126
:::warning
@@ -135,9 +135,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
135
135
:::
136
136
137
137
138
-
#### `-f <FEE_RECORDS>`
139
138
#### `--fee-records <FEE_RECORDS>`
140
-
139
+
#### `-f <FEE_RECORDS>`
141
140
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
Copy file name to clipboardExpand all lines: documentation/cli/08_execute.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,8 +116,8 @@ Broadcasts the transaction to the network upon successful execution. Without pa
116
116
#### `--save <SAVE>`
117
117
Saves the transaction to the directory located at the `<SAVE>` path.
118
118
119
-
#### `-y`
120
119
#### `--yes`
120
+
#### `-y`
121
121
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
122
122
123
123
:::warning
@@ -131,10 +131,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
131
131
1 Credit == 1,000,000 Microcreditss
132
132
:::
133
133
134
-
135
-
#### `-f <FEE_RECORDS>`
136
134
#### `--fee-records <FEE_RECORDS>`
137
-
135
+
#### `-f <FEE_RECORDS>`
138
136
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
Copy file name to clipboardExpand all lines: documentation/cli/15_upgrade.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,8 +52,8 @@ Broadcasts the transaction to the network upon successful execution. Without pa
52
52
#### `--save <SAVE>`
53
53
Saves the transaction to the directory located at the `<SAVE>` path.
54
54
55
-
#### `-y`
56
55
#### `--yes`
56
+
#### `-y`
57
57
The CLI will ask for manual confirmation on several steps throughout the deployment process. Setting this flag automatically agrees to all confirmations.
58
58
59
59
:::warning
@@ -67,10 +67,8 @@ Specifes the priority fee for the deployment transaction(s) delimited by `|` and
67
67
1 Credit == 1,000,000 Microcreditss
68
68
:::
69
69
70
-
71
-
#### `-f <FEE_RECORDS>`
72
70
#### `--fee-records <FEE_RECORDS>`
73
-
71
+
#### `-f <FEE_RECORDS>`
74
72
Specifes the record(s) to pay for fees privately, delimited by `|` and used in order. The fees must either be valid plaintext, ciphertext, or `default`. If not specified, then transaction fees will be public.
This command is used to generate proving and verifying keys for all transitions in a local or remote Leo program, along with circuit metadata.
13
+
14
+
```bash
15
+
leo synthesize <PROGRAM_NAME> --save <SAVE_DIRECTORY>
16
+
```
17
+
18
+
Each output of this command includes:
19
+
- Number of public inputs
20
+
- Number of variables
21
+
- Number of constraints
22
+
- Non-zero entries in matrices
23
+
- Circuit ID
24
+
- Proving and verifying keys saved to disk
25
+
26
+
This enables better understanding of program size and key management.
27
+
28
+
### Flags:
29
+
30
+
#### `--network <NETWORK>`
31
+
Specifies the network to deploy to. Overrides any `NETWORK` environment variable set manually or in a `.env` file. Valid network names are `testnet`, `mainnet`, and `canary`.
32
+
33
+
#### `--endpoint <ENDPOINT>`
34
+
The endpoint to deploy to. Overrides any `ENDPOINT` environment variable set manually or in a `.env` file.
35
+
36
+
#### `--local`
37
+
#### `-l`
38
+
Specifies that the keys should be generated for the local Leo project in the current working directory.
39
+
40
+
#### `--skip <SKIP>`
41
+
#### `-s <SKIP>`
42
+
Specifies to skip the key generation for any function names that contain the provided substrings
43
+
44
+
45
+
#### `--save <SAVE_DIRECTORY>`
46
+
The directory to save the key files to. If the provided path does not exist, it will be created in your current working directory.
Copy file name to clipboardExpand all lines: documentation/language/02_structure.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,16 +125,27 @@ program hello.aleo { }
125
125
### Mappings
126
126
127
127
A mapping is declared as `mapping {name}: {key-type} => {value-type}`.
128
-
Mappings contain key-value pairs.
129
-
Mappings are stored on chain.
128
+
Mappings contain key-value pairs and stored on chain.
130
129
131
-
```leo showLineNumbers
130
+
```leo
132
131
// On-chain storage of an `account` mapping,
133
132
// with `address` as the type of keys,
134
133
// and `u64` as the type of values.
135
134
mapping account: address => u64;
136
135
```
137
136
137
+
### Storage
138
+
A storage variable is declared as `storage {name}: {type}`. Storage variables contain singleton values. They are declared at program scope and are stored on chain, similar to mappings.
139
+
```leo
140
+
// On-chain storage of an `counter` storage variable of type u32,
141
+
storage counter: u32;
142
+
```
143
+
A storage vector is declared as `storage {name}: [{type}]`. Storage vectors contain dynamic lists of values of a given type. They are declared at program scope and are stored on chain, similar to mappings.
144
+
```leo
145
+
// On-chain storage of an `accounts` storage vector of type address,
146
+
storage accounts: [address];
147
+
```
148
+
138
149
### Struct
139
150
140
151
A struct data type is declared as `struct {name} {}`.
As of v2.7.0, Leo supports type inference. The Leo compiler is able to infer the types of declared variables and expressions as long as the type can be **unambiguously determined** from the surrounding context.
10
-
11
-
If the compiler cannot infer the type, you must provide an explicit type annotation.
12
-
13
-
Here are some examples:
14
-
```leo
15
-
let a: u8 = 2u8; // explicit type - allowed
16
-
let b = 2u8; // type inference - allowed
17
-
let c : u8 = 2; // type inference - allowed
18
-
19
-
let d = 2; // ambiguous type - not allowed
20
-
```
21
-
22
-
Type inference also applies to members within a struct:
23
-
```leo
24
-
struct Foo {
25
-
x: u8
26
-
}
27
-
28
-
let f = Foo {
29
-
x: 5, // inferred to be a `u8`
30
-
};
31
-
```
32
-
33
8
34
9
## Types
35
10
@@ -61,20 +36,19 @@ let n: u64 = 1_000_000u64;
61
36
Higher bit length integers generate more constraints in the circuit, which can slow down computation time.
62
37
:::
63
38
64
-
#### A Note on Leo Integers
65
-
39
+
:::info
66
40
Leo does not assume a default integer type. Every integer must either have an **explicit type annotation** or a type that can be **inferred by the compiler**.
67
41
68
42
```leo
69
43
let a: u8 = 2u8; // explicit type
70
44
let b: u16 = a as u16; // type casting
71
45
```
46
+
:::
72
47
73
48
### Field Elements
74
49
75
50
Leo supports the `field` type for elements of the base field of the elliptic curve.
76
-
These are unsigned integers less than the modulus of the base field. The following are the
77
-
smallest and largest field elements.
51
+
These are unsigned integers less than the modulus of the base field. The following are the smallest and largest field elements.
Note that generic structs cannot currently be imported outside a program, but can be declared and used in submodules. Acceptable types for const generic parameters include integer types, `bool`, `scalar`, `group`, `field`, and `address`.
237
+
238
+
## Option Types
239
+
As of v3.3.0, Leo supports first-class option types using the `T?` syntax, where `T` is any of the types previously mentioned, excluding `address`, `signature`, and `tuple`. A value of type `T?` can be initialized into two states: either a value of type `T`, or `none`:
240
+
```leo
241
+
let w: u8? = 42u8;
242
+
let x: u8? = none;
243
+
```
244
+
A value of type `T?` can be converted to type `T` by calling the `.unwrap()` method on the value. Note that if the value being unwrapped is `none`, then the program will fail to execute. To unwrap the value with a fallback for this case, call the `.unwrap_or()` method:
245
+
```leo
246
+
let y = w.unwrap(); // Returns 42u8
247
+
let z = x.unwrap_or(99u8); // Returns 99u8
248
+
```
249
+
Option types can also be stored in arrays and structs:
250
+
```leo
251
+
// Struct of options
252
+
struct Point {
253
+
x: u32?,
254
+
y: u32?
255
+
}
256
+
257
+
// Array of options
258
+
let arr: [u16?; 2] = [1u16, none];
259
+
let first_val = arr[0].unwrap(); // Returns 1u16
260
+
let second_val = arr[1].unwrap_or(0u16); // Returns 0u16
As of v2.7.0, Leo supports type inference. The Leo compiler is able to infer the types of declared variables and expressions as long as the type can be **unambiguously determined** from the surrounding context.
269
+
270
+
If the compiler cannot infer the type, you must provide an explicit type annotation.
271
+
272
+
Here are some examples:
273
+
```leo
274
+
let a: u8 = 2u8; // explicit type - allowed
275
+
let b = 2u8; // type inference - allowed
276
+
let c : u8 = 2; // type inference - allowed
277
+
278
+
let d = 2; // ambiguous type - not allowed
279
+
```
280
+
281
+
Type inference also applies to members within a struct:
0 commit comments