Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix hello contract now expose get_name and set_name to abi correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
NameX44 committed Mar 19, 2024
1 parent 378e645 commit f115452
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/ch02-02-starkli-scarb-katana.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Deploying a Starknet smart contract requires two primary steps:
Begin with the `src/lib.cairo` file, which provides a foundational template. Remove its contents and insert the following:

```rust
#[starknet::interface]
trait IHello<T> {
fn get_name(self: @T) -> felt252;
fn set_name(ref self: T, name: felt252);
}

#[starknet::contract]
mod hello {
#[storage]
Expand All @@ -91,12 +97,14 @@ mod hello {
}

#[abi(embed_v0)]
fn get_name(self: @ContractState) -> felt252 {
self.name.read()
}
#[abi(embed_v0)]
fn set_name(ref self: ContractState, name: felt252) {
self.name.write(name);
impl HelloImpl of super::IHello<ContractState> {
fn get_name(self: @ContractState) -> felt252 {
self.name.read()
}

fn set_name(ref self: ContractState, name: felt252) {
self.name.write(name);
}
}
}

Expand Down

0 comments on commit f115452

Please sign in to comment.