Created
August 10, 2023 09:50
-
-
Save codeWhizperer/5d95e6547f8e763f1680d3bc2b59de8e 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
| #[starknet::interface] | |
| trait IHelloStarknet<TContractState> { | |
| fn increase_balance(ref self: TContractState, amount: felt252); | |
| fn get_balance(self: @TContractState) -> felt252; | |
| } | |
| #[starknet::contract] | |
| mod HelloStarknet { | |
| #[storage] | |
| struct Storage { | |
| balance: felt252, | |
| } | |
| #[external(v0)] | |
| impl HelloStarknetImpl of super::IHelloStarknet<ContractState> { | |
| fn increase_balance(ref self: ContractState, amount: felt252) { | |
| assert(amount != 0, 'Amount cannot be 0'); | |
| self.balance.write(self.balance.read() + amount); | |
| } | |
| fn get_balance(self: @ContractState) -> felt252 { | |
| self.balance.read() | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment