Skip to content

Conversation

@jayjose1
Copy link
Owner

https://sway-playground.org/?ref=fuel-labs.ghost.io
Screenshot_19

contract;

abi TestContract {
#[storage(read, write)]
fn increment_counter(amount: u64) -> u64;

#[storage(read)]
fn get_counter() -> u64;

}

storage {
counter: u64 = 0,
}

impl TestContract for Contract {
#[storage(read, write)]
fn increment_counter(amount: u64) -> u64 {
let incremented = storage.counter.read() + amount;
storage.counter.write(incremented);
incremented
}

#[storage(read)]
fn get_counter() -> u64 {
    storage.counter.read()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants