Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Prerequisites

Icon LinkPrerequisites

Icon LinkInstallation

To install the Fuel toolchain, you can 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 https://install.fuel.network | sh
Icon InfoCircle

Having problems? Visit the installation guide or post your question in our forum Icon Link.

If you're using VSCode, we recommend installing the Sway extension Icon Link.

Icon LinkAlready have fuelup installed?

If you already have fuelup installed, run the commands below to make sure you are on the most up-to-date toolchain.

fuelup self update
fuelup update
fuelup default latest

Icon LinkFuel Wallet

Our frontend application will allow users to connect with a wallet, so you'll need to have a browser wallet installed.

Before going to the next steps, install the Fuel Wallet Icon Link extension.

Once you've setup your wallet, click the "Faucet" button in the wallet to get some testnet tokens.

Additionally for this guide, ensure you're using Node.js/npm version 18.20.3 || ^20.0.0 || ^22.0.0. You can check your Node.js version with:

node -v

Icon LinkProject Setup

Start with a Fuel template and name it sway-store.

pnpm create fuels --pnpm sway-store

Go into the sway-store folder:

cd sway-store

There should already be a folder called sway-programs inside, where your Sway programs will live. Ignore the other programs as we will only focus on the contract program type in this tutorial. Move into your contract folder:

cd sway-programs/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.