Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added starknet_contracts/src/contracts/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions starknet_contracts/src/contracts/HelloStarknet.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// Simple contract for managing balance.
#[Starknet::contract]
#[starknet::contract]
pub mod HelloStarknet {

use Starknet_contracts::interfaces::IHelloStarknet::IHelloStarknet;
use starknet_contracts::interfaces::IHelloStarknet::IHelloStarknet;
// use Starknet::storage::{StoragePointerReadAccess, StoragePathEntry, StoragePointerWriteAccess, Map };
use Starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess };
use Starknet::{ContractAddress, get_caller_address};
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess };
use starknet::{ContractAddress, get_caller_address};

#[storage]
struct Storage {
Expand All @@ -14,12 +14,12 @@ pub mod HelloStarknet {
}

#[event]
#[derive(Drop, Starknet::Event)]
#[derive(Drop, starknet::Event)]
pub enum Event {
Balance : BalanceIncreased,
}

#[derive(Drop, Starknet::Event)]
#[derive(Drop, starknet::Event)]
pub struct BalanceIncreased {
pub caller: ContractAddress,
pub amount: felt252,
Expand Down
46 changes: 46 additions & 0 deletions starknet_contracts/src/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Session 5b Assignment: sncast Deployment

## First Step:

created an account using below command in my terminal

" sncast create --url <SEPOLIA RPC URL> --name <ACCOUNT NAME> "

## Second Step:

funded the address gotten from the first step:
go to https://starknet-faucet.vercel.app/ to fund your account.

### note :

funding your account is crucial before proceeding to step 3.

## Step three:

Deployed the account using:
sncast deploy --url <SEPOLIA RPC URL> --name <ACCOUNT NAME>

## Step Four:

Deployed my Counter contract:

## Step Five:

Interacted with the Counter contract:

## Tested the get_count function with sncast call

Result :
![Account creation](01.png)

## Tested increment function with sncast invoke

Result :
![Increment](increment.png)

## Tested decrement function with sncast invoke

Result :
![Increment](decrement.png)

At the end of the practice i was able to deploy with sncast and testes my functions using call and invoke methods in sncast.
23 changes: 17 additions & 6 deletions starknet_contracts/src/contracts/counter.cairo
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#[Starknet::contract]
#[starknet::contract]
pub mod Counter {
// use Starknet::ContractAddress;
// use Starknet::get_caller_address;
use Starknet_contracts::interfaces::ICounter::ICounter;
use Starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
use starknet_contracts::interfaces::ICounter::ICounter;
use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};

#[storage]
struct Storage {
count: u32,
}

#[event]
#[derive(Drop, Starknet::Event)]
#[derive(Drop, starknet::Event)]
pub enum Event {
CountUpdated : CountUpdated,
}

#[derive(Drop, Starknet::Event)]
#[derive(Drop, starknet::Event)]
struct CountUpdated {
old_value: u32,
new_value: u32,
Expand Down Expand Up @@ -48,4 +48,15 @@ pub mod Counter {
self.emit(CountUpdated { old_value, new_value });
}
}
}
}

// sncast deploy --url https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_8/Z8ps3lEeb_j7VOniV_nSVx4o1940CLWl --cl
// ass-hash 0x03c4cf8f4d177e4ee089f46fa8ac00e628ebc2304acfaa004c95c79eab03963a
// command: deploy
// contract_address: 0x00c8fe524538e9c04d6254e4b928d847c8cd0da8572f01fa40d37307b20e229b
// transaction_hash: 0x0638e2f68620df0e28a77fe004295657f49fa881938fc600a28f98ed7c7efccd


// To see deployment details, visit:
// contract: https://sepolia.starkscan.co/contract/0x00c8fe524538e9c04d6254e4b928d847c8cd0da8572f01fa40d37307b20e229b
// transaction: https://sepolia.starkscan.co/tx/0x0638e2f68620df0e28a77fe004295657f49fa881938fc600a28f98ed7c7efccd
Binary file added starknet_contracts/src/contracts/decrement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added starknet_contracts/src/contracts/increment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.