##Install Dependencies ----
sudo apt update
sudo apt upgrade -y
sudo apt-get install curl screen -y
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustc --version
rustup install stable
rustup update stable
rustup default stable
sudo apt install git -y
curl https://install.fuel.network | sh
source /root/.bashrc
fuelup toolchain install latest
fuelup self update
fuelup update && fuelup default latest
mkdir fuel-project && cd fuel-project
forc new counter-contract
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);
}
}
cd counter-contract
forc build
Remember, you will need your FUEL wallet here, i will be importing mine, if you don't have wallet, Install from here
forc wallet import
forc wallet account new
forc wallet accounts
forc deploy --testnet