Created
October 6, 2022 16:31
-
-
Save PowerStream3604/698b23e5f752e993ed0a7dcb8c0aaa90 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
%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