Skip to content

Instantly share code, notes, and snippets.

@DavideSilva
Created August 4, 2023 14:43
Show Gist options
  • Save DavideSilva/6fe404960555cb7c738fa4f9f2793813 to your computer and use it in GitHub Desktop.
Save DavideSilva/6fe404960555cb7c738fa4f9f2793813 to your computer and use it in GitHub Desktop.
#[starknet::interface]
trait IMyFirstContract<ContractState> {
fn get_value(self: @ContractState) -> u64;
}
#[starknet::contract]
mod MyFirstContract {
#[storage]
struct Storage {
value: u64
}
#[constructor]
fn constructor(ref self: ContractState) {
self.value.write(1)
}
#[external(v0)]
impl PublicFunctions of super::IMyFirstContract<ContractState> {
fn get_value(self: @ContractState) -> u64 {
self.value.read()
}
}
#[external(v0)]
impl OtherTraitImplementation of super::IMyFirstContract<ContractState> {
fn get_value(self: @ContractState) -> u64 {
self.value.read()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment