Hello @calldelegation, thank you.
- Here’s the compilation error it shows using
forc build
in the root directory of my Sway project:
sheys@DESKTOP-MRD72SV:~/fuelvm-projects/counter$ forc build
Compiling library core (/home/sheys/.forc/git/checkouts/std-9be0d6062747ea7/512a3386f8961185188302f391ccc96553d23a7a/sway-lib-core)
Compiling library std (git+https://github.com/fuellabs/sway?tag=v0.46.1#512a3386f8961185188302f391ccc96553d23a7a)
Compiling contract counter (/home/sheys/fuelvm-projects/counter)
warning
--> /home/sheys/fuelvm-projects/counter/src/main.sw:5:5
|
3 |
4 | //declare a storage variable
5 | counter: u64 = 0,
| ------- This storage declaration is never accessed and can be removed.
6 | }
|
____
error
--> /home/sheys/fuelvm-projects/counter/src/main.sw:22:16
|
20 |
21 | //using implicit return
22 | return storage.counter;
| ^^^^^^^^^^^^^^^ Mismatched types.
expected: u64
found: StorageKey<u64>.
help: Return statement must return the declared function return type.
23 |
24 | }
|
____
error
--> /home/sheys/fuelvm-projects/counter/src/main.sw:28:9
|
26 |
27 | fn increment() {
28 | storage.counter = storage.counter + 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This expression is not valid on the left hand side of a reassignment.
29 | }
30 | }
|
____
error
--> /home/sheys/fuelvm-projects/counter/src/main.sw:20:5
|
18 |
19 | #[storage(read)]
20 | fn counter() -> u64 {
| _____^
21 | | //using implicit return
22 | | return storage.counter;
23 | |
24 | | }
| |_____^ This path must return a value of type "u64" from function "counter", but it does not.
25 |
26 | #[storage(read, write)]
|
____
Aborting due to 3 errors.
Error: Failed to compile counter
I recently read that there’s a storage issue with beta-4 testnet here, I don’t think that has been resolved yet… But how can I move forward?
- Regarding point 2, thanks for the information