Last active
January 5, 2023 19:34
-
-
Save SilentCicero/25bbd4d5b5a72e1242840c36985b0522 to your computer and use it in GitHub Desktop.
A simple counter Sway contract.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract; | |
use sway_libs::i8::I8; | |
abi TestContract { | |
#[storage(write)] | |
fn initialize_counter(value: u64) -> u64; | |
#[storage(read, write)] | |
fn increment_counter(amount: u64) -> u64; | |
} | |
storage { | |
counter: u64 = 0, | |
} | |
impl TestContract for Contract { | |
#[storage(write)] | |
fn initialize_counter(value: u64) -> u64 { | |
let something = I8::max(); | |
storage.counter = value; | |
value | |
} | |
#[storage(read, write)] | |
fn increment_counter(amount: u64) -> u64 { | |
let incremented = storage.counter + amount; | |
storage.counter = incremented; | |
incremented | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment