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.

Make sure you have the latest version of the Fuel Wallet Icon Link installed.

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

node -v

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.