Skip to content

Instantly share code, notes, and snippets.

@PowerStream3604
Created October 6, 2022 16:31
Show Gist options
  • Save PowerStream3604/698b23e5f752e993ed0a7dcb8c0aaa90 to your computer and use it in GitHub Desktop.
Save PowerStream3604/698b23e5f752e993ed0a7dcb8c0aaa90 to your computer and use it in GitHub Desktop.
%lang starknet
from starkware.cairo.common.cairo_builtins import HashBuiltin
// Define a storage variable.
@storage_var
func balance() -> (res: felt) {
}
// Increases the balance by the given amount.
@external
func increase_balance{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr,
}(amount: felt) {
let (res) = balance.read();
balance.write(res + amount);
return ();
}
// Returns the current balance.
@view
func get_balance{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr,
}() -> (res: felt) {
let (res) = balance.read();
return (res=res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment