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
***sum** - this is a global variable, a `SingleValueMapper` (a single value) of type BigUint (unsigned integer);
34
35
***init** - the constructor;
35
36
***add** - function that increments the global variable (`sum`) with the `value` parameter;
36
37
***upgrade** - function executed when upgrading the contract.
37
38
38
39
We notice 5 types of annotations:
40
+
39
41
*`#[view(getSum)]` - this is a function that allows you to read the storage variable by calling the function `getSum`;
40
42
*`#[storage_mapper("sum")]` - this is a global **variable** (also called a storage) stored at the contract address;
41
43
*`#[init]` - the constructor function; this is called when deploying the contract;
42
44
*`#[upgrade]` - this function is called when upgrading the contract;
43
45
*`#[endpoint]` - an endpoint is a function callable directly by the user; A function not having this annotation will not be exposed publicly.
44
46
47
+
[Here](https://github.com/multiversx/mx-contracts-rs/blob/main/contracts/adder/src/adder.rs) is the smart contract code listed above and [here](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/adder) are all the files needed for compilation.
45
48
46
-
[Here](https://github.com/multiversx/mx-contracts-rs/blob/main/contracts/adder/src/adder.rs) is the smart contract code listed above and [here](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/adder) are all the files needed for compilation.
49
+
You can obtain the adder smart contract code directly using the following command:
47
50
51
+
```bash
52
+
sc-meta new --template adder
53
+
```
54
+
55
+
Let's build the smart contract, running the next command in the contract root:
56
+
57
+
```sh
58
+
sc-meta all build
59
+
```
48
60
49
-
Let's compile the contract:
61
+
Below, it is the output of the command:
50
62
51
63
```bash
52
-
costin@Byblos:~/mvx/mx-contracts-rs/contracts/adder$ sc-meta all build
53
-
/home/costin/mvx/mx-contracts-rs/contracts/adder
64
+
/home/adder
54
65
55
66
Found 1 contract crates.
56
67
57
68
(1/1)
58
-
In /home/costin/mvx/mx-contracts-rs/contracts/adder/meta
69
+
In /home/adder/meta
59
70
Calling `cargo run build`
60
-
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
0 commit comments