āŒ˜K

Icon SunFilledIcon MoonStars
Prerequisites

Icon LinkInstallation

The Fuel toolchain is built on top of the Rust programming language. To install Rust, you can use the rustup tool.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

To install the Fuel toolchain, you'll use the fuelup-init script. This will install forc, forc-client, forc-fmt, forc-lsp, forc-wallet as well as fuel-core in ~/.fuelup/bin.

curl --proto '=https' --tlsv1.2 -sSf https://install.fuel.network/fuelup-init.sh | sh

šŸ‘‰ Run the following command to install the beta-4 toolchain:

fuelup toolchain install beta-4

šŸ‘‰ Set beta-4 as your default toolchain with the following command:

fuelup default beta-4

For more detailed instructions on installing fuelup, visit the installation guide .

Having problems with this part? Post your question on our forum Icon Link. To help you as efficiently as possible, include the output of this command in your post: fuelup show.

Additionally for this guide, ensure you're using Node.js/npm version 18.14.1 or higher (up to node.js 19.0.0). Check your Node.js version with:

node -v

Update node.js if your version is below 18.14.1.

Icon LinkProject Setup

Start with a new empty folder and name it fuel-project.

mkdir fuel-project

Go into the fuel-project folder:

cd fuel-project

Within your terminal start by creating a new sway project called contract:

forc new contract

Your project structure generated from the forc command should like this:

tree contract
contract
ā”œā”€ā”€ Forc.toml
ā””ā”€ā”€ src
    ā””ā”€ā”€ main.sw

1 directory, 2 files

Move into your contract folder:

cd contract

Open up the contract folder in VSCode, and inside the src folder you should see a file called main.sw. This is where you will write your Sway contract.

Since we're creating a brand new contract you can delete everything in this file except for the contract keyword.

contract;

The first line of the file is specifically reserved to inform the compiler whether we are writing a contract, script, predicate, or library. To designate the file as a contract, use the contract keyword.