HelloStarknet
contract, which will be used throughout the following installments.
HelloStarknet
HelloStarknet
contract can be generated by simply running:
Starknet Foundry (default)
test runner. If successful, this should create a new hello_starknet
directory with the following structure:
HelloStarknet
hello_starknet
directory other than hello_starknet/src/lib.cairo
, which holds the contract’s code:
HelloStarknet
is a simple contract for managing balance. Specifically:
#[starknet::contract]
attribute.#[starknet::interface]
attribute. Here, our contract defines and publicly exposes the functions increase_balance
and get_balance
.Storage
struct, which is always initialized empty. Here, our struct contains a single field called balance
of type felt252
.#[abi(embed_v0)]
attribute to expose the implementations to the outside world. Here, increase_balance
uses the write
method to increase balance
by amount
and get_balance
uses the read
method to return the value of balance
.HelloStarknet
contract’s storage will be recorded in Starknet’s history.