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/guides/01_async.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ The execution of on-chain code is treated as an `async function` call which retu
14
14
15
15
## Managing Public State
16
16
17
-
On-chain data is stored in publicly in one of three data structures: mappings, storage variables, and storage vectors Any logic that reads from or updates the state of these structures must be contained within an `async function` block as follows:
17
+
On-chain data is stored publicly in one of three data structures: mappings, storage variables, and storage vectors. Any logic that reads from or updates the state of these structures must be contained within an `async function` block as follows:
18
18
19
19
```leo
20
20
program first_public_state.aleo {
@@ -23,13 +23,13 @@ program first_public_state.aleo {
23
23
storage queue: [u8];
24
24
25
25
async function increment_state_onchain(){
26
-
let current_count: u64 = accumulator.get_or_use(0u8, 0u64); // Get current value, default 0
26
+
let current_count: u64 = accumulator.get_or_use(0u8, 0u64); // Get current value, defaults to 0
27
27
let new_count: u64 = current_count + 1u64;
28
28
accumulator.set(0u8, new_count);
29
29
}
30
30
31
31
async function increment_count_onchain(){
32
-
let current_count: u8 = count.unwrap_or(0u8); // Get current value, default 0
32
+
let current_count: u8 = count.unwrap_or(0u8); // Get current value, defaults to 0
33
33
count = current_count + 1u8;
34
34
}
35
35
@@ -56,7 +56,7 @@ program first_public_state.aleo {
56
56
return increment_state_onchain();
57
57
}
58
58
async function increment_accumulator_onchain(){
59
-
let current_count: u64 = accumulator.get_or_use(0u8, 0u64); // Get current value, default 0
59
+
let current_count: u64 = accumulator.get_or_use(0u8, 0u64); // Get current value, defaults to 0
60
60
let new_count: u64 = current_count + 1u64;
61
61
accumulator.set(0u8, new_count);
62
62
}
@@ -68,7 +68,7 @@ program first_public_state.aleo {
68
68
return increment_count_onchain();
69
69
}
70
70
async function increment_count_onchain(){
71
-
let current_count: u8 = count.unwrap_or(0u8); // Get current value, default 0
71
+
let current_count: u8 = count.unwrap_or(0u8); // Get current value, defaults to 0
72
72
count = current_count + 1u8;
73
73
}
74
74
@@ -96,7 +96,7 @@ program first_public_state.aleo {
0 commit comments