Skip to content

Deploy Contract on the latest network [Testnet before Mainnet]

Notifications You must be signed in to change notification settings

Kayne-dev/Fuel-Contract-Deployment

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation


Deploying a Contract on Fuel Network

image

##Install Dependencies ----

sudo apt update
sudo apt upgrade -y
sudo apt-get install curl screen -y 

image

Installing RUST

curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustc --version

image

rustup install stable
rustup update stable
rustup default stable

image

Install GIT

image

sudo apt install git -y 

Install Fuel Toolchain

image

curl https://install.fuel.network | sh

press y then enter

image

Setting PATH

image

source /root/.bashrc

Setting FUELUP

fuelup toolchain install latest
fuelup self update
fuelup update && fuelup default latest

Creating PROJECT

image

mkdir fuel-project && cd fuel-project
forc new counter-contract

Editing Contract

image

nano counter-contract/src/main.sw

Clear/delete everything and paste below code

contract;
 
storage {
    counter: u64 = 0,
}
 
abi Counter {
    #[storage(read, write)]
    fn increment();
 
    #[storage(read)]
    fn count() -> u64;
}
 
impl Counter for Contract {
    #[storage(read)]
    fn count() -> u64 {
        storage.counter.read()
    }
 
    #[storage(read, write)]
    fn increment() {
        let incremented = storage.counter.read() + 1;
        storage.counter.write(incremented);
    }
}

Save and exit with Ctrl X + y and click ENTER


Build Contract

image

cd counter-contract
forc build 

image

Deploying Contract

Remember, you will need your FUEL wallet here, i will be importing mine, if you don't have wallet, Install from here

image

Importing wallet

image

forc wallet import 

image

and copy and paste on terminal

image

Note: password are always invincible


Create Account

forc wallet account new

image

Import account and input password

Check Address

forc wallet accounts

Deploy Contract

image

forc deploy --testnet 

Enter 0 as Index and click y

image

CONTRACT DEPLOYED


EXPLORER

FUEL EXPLORER


About

Deploy Contract on the latest network [Testnet before Mainnet]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published