Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Contract Quickstart

Icon LinkSmart Contract Quickstart

Getting started with Fuel as a smart contract developer is as simple as:

  1. Installing fuelup
  2. Generating a counter contract
  3. Building and deploying the contract

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 LinkDevnet toolchain

To use the devnet toolchain, run the commands below:

fuelup self update
fuelup toolchain install devnet
fuelup default devnet

Icon LinkGenerating a counter contract

Run the command below to generate a counter contract in Sway:

forc template --template-name counter counter-contract

The contract will be in the src/main.sw file.

Here is the project that forc has initialized:

tree counter-contract
counter-contract
├── Forc.toml
└── src
    └── main.sw

1 directory, 2 files

forc.toml is the manifest file (similar to Cargo.toml for Cargo or package.json for Node) and defines project metadata such as the project name and dependencies.

Icon LinkBuilding and deploying the contract

To build a contract, move inside the counter-contract folder:

cd counter-contract

Next, run the forc build command:

forc build

To deploy the contract to the devnet, you can run:

forc deploy --testnet

The terminal will ask for the password of the wallet:

Please provide the password of your encrypted wallet vault at "~/.fuel/wallets/.wallet":

Once you have unlocked the wallet, the terminal will show a list of the accounts:

Account 0 -- fuel18caanqmumttfnm8qp0eq7u9yluydxtqmzuaqtzdjlsww5t2jmg9skutn8n:
  Asset ID                                                           Amount
  0000000000000000000000000000000000000000000000000000000000000000 499999940

Just below the list, you'll see this prompt:

Please provide the index of account to use for signing:

Then you'll enter the number of the account of preference and press Y when prompted to accept the transaction.

Finally, you will get back the network endpoint where the contract was deployed, a Contract ID and the block where the transaction was signed.

Icon LinkNext Steps

Ready to learn more? Check out the following resources: