Note that if you want to run Sway smart contracts (e.g. for testing), a Fuel Core full node is required. Otherwise, the Sway toolchain is sufficient to compile Sway smart contracts.
Pre-compiled release binaries for Linux and macOS are available for the Sway toolchain. Native Windows is currently unsupported (tracking issue for Windows support). Windows Subsystem for Linux should work but is not officially supported.
fuelup is the equivalent of Rust's
rustup for the Sway toolchain. It enables easily downloading binary releases of the Sway toolchain.
Start by installing
curl --proto '=https' --tlsv1.2 -sSf \ https://fuellabs.github.io/fuelup/fuelup-init.sh | sh -s install
You may need to add
~/.fuelup/bin to your PATH. For Bash:
to install the latest Sway toolchain.
curl: (22) The requested URL returned error: 404error when running any of the steps above is most likely an indication that a new release was published but binaries were not yet uploaded by CI. See: https://github.com/FuelLabs/fuelup/issues/44. Simply re-try the commands after binaries are uploaded.
A prerequisite for installing and using Sway is the Rust toolchain. Platform-specific instructions for installing
rustup can be found here. Then, install the Rust toolchain with:
# Install the latest stable Rust toolchain. rustup install stable
fuel-core may require installing additional system dependencies. See here for instructions.
The Sway toolchain is built and tested against the
stable Rust toolchain version (https://github.com/rust-lang/rust/releases/latest). There is no guarantee it will work with the
nightly Rust toolchain, or with earlier
stable versions, so ensure you are using
# Update installed Rust toolchain; can be used independently. rustup update # Set the stable Rust toolchain as default; can be used independently. rustup default stable
The Sway toolchain and Fuel Core full node can be installed from source with Cargo with:
cargo install forc fuel-core
You can update the toolchain from source with Cargo with:
cargo install forc fuel-core
The Fuel ecosystem has a few plugins which can be easily installed via Cargo.
forcdetects anything in your
forc-as a plugin. Use
forc pluginsto see what you currently have installed.
# Sway Formatter cargo install forc-fmt # Block Explorer cargo install forc-explore # Sway Language Server cargo install forc-lsp
Rather than installing from
cargo, the Sway toolchain can be built from a local source checkout by following instructions at https://github.com/FuelLabs/sway. The Fuel Core full node implementation can be built from source by following instructions at https://github.com/FuelLabs/fuel-core.
forc supports generating completion scripts for Bash, Fish, Zsh, and PowerShell. See
forc completions --help for full details, but the gist is as simple as using one of the following:
# Bash forc completions --shell=bash > ~/.local/share/bash-completion/completions/forc # Bash (macOS/Homebrew) forc completions --shell=bash > $(brew --prefix)/etc/bash_completion.d/forc.bash-completion # Fish mkdir -p ~/.config/fish/completions forc completions --shell=fish > ~/.config/fish/completions/forc.fish # Zsh forc completions --shell=zsh > ~/.zfunc/_forc # PowerShell v5.0+ forc completions --shell=powershell >> $PROFILE.CurrentUserCurrentHost # or forc completions --shell=powershell | Out-String | Invoke-Expression
Once the completions have been generated and properly installed, close and reopen your terminal for the new completions to take effect.