Skip to content

Commit

Permalink
[bug]:contract deployment instructions #138 (#151)
Browse files Browse the repository at this point in the history
Co-authored-by: pheobeayo <pheobeayo@gmail>
  • Loading branch information
pheobeayo and pheobeayo authored Feb 10, 2025
1 parent 63d2203 commit 3b85343
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 274 deletions.
129 changes: 6 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,129 +84,6 @@ To execute the main function of the script, use:
```bash
scarb cairo-run
```
<!-- Deploying smart contract on sepolia using sncast 👇 -->
# 🚀 Deploying Smart Contracts on Sepolia testnet using sncast
## 📖 Overview
This guide demonstrates how to deploy a Starknet smart contract to Sepolia testnet using `sncast`. We'll use the SimpleHelloWorld contract as an example to walk through the entire deployment process.

## ⚙️ Steps to Deploy Your Contract

### 1. 🏗️ Building the Contract

First, let's prepare and build our contract:
```bash
# Navigate to the contract directory
cd starknet/contracts/hello_world
# Build the contract
scarb build
# Run tests to verify everything works
scarb test
```
### 2. 👤 Account Setup
#### Create New Account
```bash
sncast account create \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--name my_deployer_account
```
⚠️ **Important**: Save the output address and max_fee information
In this case, account address : 0x03d18e21dcb1f460c287af9b84e6da83b5577569e69371d39ad3415067abdbc4
![Account Creation](https://github.com/user-attachments/assets/a1038a13-4860-496e-9584-9d7c540aaf23)
🔍 View your account at:
https://sepolia.starkscan.co/contract/0x03d18e21dcb1f460c287af9b84e6da83b5577569e69371d39ad3415067abdbc4
#### Get Test Tokens (or fund with Sepolia test tokens from existing braavos or argent x wallet )
1. Visit [Sepolia STRK Faucet](https://faucet.sepolia.starknet.io/strk)
2. Visit [Sepolia ETH Faucet](https://faucet.sepolia.starknet.io/eth)
3. Request tokens for your account address
4. Monitor on [Starkscan](https://sepolia.starkscan.co)
#### Deploy Account
```bash
sncast account deploy \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--name my_deployer_account
```
![Account Deployment](https://github.com/user-attachments/assets/23ef6213-8a84-477f-8fd1-51a76558d558)
🔍 Track deployment:
https://sepolia.starkscan.co/tx/0x073e6c7e7efea34708a73fcfdbfa5fef911e5516a5e7ea6b48814c6d4c4bd281
### 3. 📄 Contract Deployment
#### Declare Contract
```bash
sncast --account my_deployer_account declare \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--contract-name SimpleHelloWorld
```
⚠️ **Important**: Save the class_hash from the output
![Contract Declaration](https://github.com/user-attachments/assets/f1db05e8-5e5c-49c3-8464-77ec9c88ab19)
Class-hash : 0x0574f6f6f9c70bbbcd08260a78653e1a21e48c4027375d2113e286883c9e513f
🔍 Verify declaration:
- Class: https://sepolia.starkscan.co/class/0x0574f6f6f9c70bbbcd08260a78653e1a21e48c4027375d2113e286883c9e513f
- Transaction: https://sepolia.starkscan.co/tx/0x00a678cb5bfed2508583f27e82879dd1e2f7c6010b1b8435c7829def3192bc24
#### Deploy Contract
```bash
sncast --account my_deployer_account deploy \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--class-hash 0x0574f6f6f9c70bbbcd08260a78653e1a21e48c4027375d2113e286883c9e513f
```
![Contract Deployment](https://github.com/user-attachments/assets/014a2082-b549-4369-9040-d7e14e4ed967)
Contract deployed at address : 0x003b6059a58c96c5db118808d722f240797223900248201250e9e8b4aa34c033
🔍 Track deployment:
- Contract: https://sepolia.starkscan.co/contract/0x003b6059a58c96c5db118808d722f240797223900248201250e9e8b4aa34c033
- Transaction: https://sepolia.starkscan.co/tx/0x005abf392b7828aae946f271b5560ec54414dfaf5b324de14deb4f1fd5fa19a5
### 4. ✅ Verifying Deployment
#### Set Contract Value
```bash
sncast --account my_deployer_account invoke \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--contract-address 0x003b6059a58c96c5db118808d722f240797223900248201250e9e8b4aa34c033 \
--function set_hello_world
```
![Setting Value](https://github.com/user-attachments/assets/5239e43b-5a61-4eff-bb85-a0fd9cdf4bd2)
🔍 View transaction:
https://sepolia.starkscan.co/tx/0x076143df3b9b9341a39b205a600177f632b96b4f38430569ee3d15deb57b8466
#### Read Contract Value
```bash
sncast --account my_deployer_account call \
--url https://free-rpc.nethermind.io/sepolia-juno/v0_7 \
--contract-address 0x003b6059a58c96c5db118808d722f240797223900248201250e9e8b4aa34c033 \
--function get_hello_world
```
![Reading Value](https://github.com/user-attachments/assets/08c4bde6-7713-4e17-b8f7-5f37b1a3ee5c)
The successful execution of these steps confirms your contract is properly deployed and functional on the Sepolia testnet. 🎉
<!-- Deploying smart contract on sepolia using sncast 👆 -->
## ⚙️ Steps to build and and test contracts
Expand Down Expand Up @@ -348,7 +225,13 @@ This will install the correct versions of the tools specified in the `.tool-vers
- Always check the `.tool-versions` file in the script or contract directory before building or running.
- Use `asdf install` to ensure all required dependencies are correctly installed.

## 🚀 Deploying Smart Contracts

You can deploy your smart contracts using the IDE or on Sepolia Testnet using sncast

- For deployment using IDE, follow the steps here [Deployment of Contracts using IDE](https://github.com/KaizeNodeLabs/starkiro/docs/CONTRACT_DEPLOYMENT.md)

- Also for deployment of contracts using sncast, follow the steps here [Deployment of Contracts using sncast](https://github.com/KaizeNodeLabs/starkiro/docs/CONTRACT_DEPLOYMENT.md)


## Give us a star! ⭐
Loading

0 comments on commit 3b85343

Please sign in to comment.