CONTRACT DEPLOYMENT ON STARKNET

HEADBOY
3 min readOct 10, 2023

Below Is A Step By Step Guide On How To Deploy A Smart Contract On Starknet

FIRST STEP

Visit Remix & Click Accept On Pop Ups, Next Just At The Top Left Of Your Screen Click On PLUGIN MANAGER, & Search For Starknet, Then Click Activate, Then Proceed To Click Accept

SECOND STEP

Head To FILE EXPLORER, “Second Icon At The Top Left Corner” , Proceed To Click On Create File, Give It Any Name Of Your Choice, But End With .cairo “headboy.cairo” & Click Enter

THIRD STEP
Now Copy This Code & Paste In The File You Created Earlier & Click OK

#[starknet::interface]
trait ISimpleCounter<TContractState> {
fn get_current_count(self: @TContractState) -> u256;
fn increment(ref self: TContractState);
fn decrement(ref self: TContractState);
}

#[starknet::contract]
mod SimpleCounter {
#[storage]
struct Storage {
// Counter variable
counter: u256,
}

#[generate_trait]
#[external(v0)]
impl SimpleCounter of ISimpleCounter {
fn get_current_count(self: @ContractState) -> u256 {
return self.counter.read();
}

fn increment(ref self: ContractState) {
// Store counter value + 1
let mut counter: u256 = self.counter.read() + 1;
self.counter.write(counter);
}
fn decrement(ref self: ContractState) {
// Store counter value — 1
let mut counter: u256 = self.counter.read() — 1;
self.counter.write(counter);
}
}
}

FOURTH STEP

Click On Starknet Logo & Scroll Down, Then Change From Remote Devnet To Wallet Selection, Then Select Braavos Wallet & Approve To Connect Wallet, Next Scroll Up & Click On Compile, Proceed To Click Accept, Next Click Deploy & Declare Transaction In Wallet, Subsequently Click Deploy In Wallet

Congratulations You’ve Successfully Deployed A Smart Contract On Starknet

If You Encounter Any Issues Be Sure To Have Set Up Your Account On-chain On Braavos Wallet

--

--