explaingit

fuellabs/sway

🔥 Hot61,699RustAudience · developerComplexity · 4/5ActiveLicenseSetup · moderate

TLDR

A Rust-inspired programming language for writing smart contracts on the Fuel blockchain, with built-in safety checks and a complete toolchain for testing and deployment.

Mindmap

mindmap
  root((Sway))
    What it does
      Smart contract language
      Fuel blockchain focused
      Compile-time safety
    Key features
      Rust-inspired syntax
      Type system safety
      Forc toolchain
    Use cases
      Token contracts
      Decentralized exchanges
      On-chain logic
    Tech stack
      Rust compiler
      Fuel VM bytecode
      Cargo package manager

Things people build with this

USE CASE 1

Write a token contract that tracks balances and transfers on the Fuel blockchain.

USE CASE 2

Build a decentralized exchange where users can swap tokens without a central authority.

USE CASE 3

Create custom on-chain logic for decentralized applications running on Fuel.

Tech stack

RustFuel VMCargo

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Fuel toolchain installation and understanding of blockchain-specific concepts; standard Rust/Cargo workflow after that.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

Sway is a programming language purpose-built for writing smart contracts on the Fuel blockchain. A smart contract is a program that runs on a blockchain and automatically executes when certain conditions are met, like a vending machine that accepts a coin and releases a product without needing a person to operate it. The problem Sway addresses is that existing smart contract languages have safety and developer-experience limitations, and Fuel needed a language that could take full advantage of its own high-performance blockchain architecture. Sway is heavily inspired by Rust, borrowing its syntax, type system, and approach to safety. Like Rust, it aims to catch errors at compile time before the code is ever deployed, reducing the risk of costly bugs in live contracts. It comes with its own toolchain called Forc (Fuel Orchestrator), which handles compiling, testing, and deploying Sway programs. The language includes a standard library, and the project also provides extensive documentation through the Sway Book. You would use Sway if you are building decentralized applications on the Fuel network, for example, writing a token contract, a decentralized exchange, or any other on-chain logic. It is not a general-purpose language and is specifically designed for the Fuel blockchain environment. The tech stack is Rust used to build the Sway compiler itself; Sway code you write compiles to Fuel VM bytecode for deployment on the Fuel blockchain. Installation is through Rust's Cargo package manager.

Copy-paste prompts

Prompt 1
Show me how to write a simple token contract in Sway that tracks balances and allows transfers.
Prompt 2
How do I set up a Sway project with Forc and write a test for a smart contract?
Prompt 3
What are the key differences between Sway and Solidity for writing smart contracts?
Prompt 4
Help me compile and deploy a Sway contract to the Fuel testnet using Forc.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.