← All open source projects

Sway

FuelLabs/sway

Sway is Fuel’s language and toolchain for writing reliable smart contracts.

Forks 5,424
Author FuelLabs
Language Rust
License Apache-2.0
Synced 2026-06-27

What it is

Sway is a programming language for smart contracts in the Fuel ecosystem. It borrows ideas from Rust and applies them to blockchain development: explicit types, structured programs, build tooling, and the Forc toolchain.

It matters when a smart contract needs to be a maintainable program rather than a small script. Contract bugs can affect assets, state, and public rules that are hard to change after release.

How the approach works

Sway is tied to Forc, which creates projects, builds contracts, runs checks, and connects code to the Fuel environment. The repository is therefore a language and tooling home, not only a syntax definition.

The syntax feels close to systems programming: types, functions, storage, and contract interfaces are explicit. That makes code stricter but also demands discipline.

Contract skeleton

This example shows the shape of a Sway contract: ABI, function, and explicit return value. The page does not have Sway highlighting, so plain text is used.

Language: Plain text
contract;

abi Counter {
    #[storage(read, write)]
    fn increment() -> u64;
}

impl Counter for Contract {
    #[storage(read, write)]
    fn increment() -> u64 {
        1
    }
}

What is inside

The repository contains the compiler, Forc, libraries, tests, build documentation, and contribution material. It is a working environment around a smart-contract language.

Sway develops its own stack rather than being a thin syntax layer over unrelated tooling. That gives coherence, but it also ties the project to Fuel.

Practical context

In practice, Sway should be studied together with Forc, local tests, and Fuel documentation. The language provides syntax, but contract reliability also needs checks, audits, and network constraints.

Strengths and limits

The main strength is bringing stricter engineering habits into smart contracts: language, compiler, and build tool evolve together.

The limit is ecosystem fit. Sway is useful for Fuel projects; other chains usually impose their own languages, wallets, tools, and audit practices.