Sway
@SwayLang
Followers
125K
Following
1K
Media
300
Statuses
1K
Sway is a Rust-based, domain specific language for writing smart contracts, created by @fuel_network.
Joined November 2021
Sway is a language purpose-built for blockchains. It combines the best of Solidity and Rust, providing a full suite of tools for creating secure, high-performance Dapps. đ§”
58
170
594
10 Years of experience with simulated trading. Turn your skills into rewards now!
0
5
16
Swayâs treasure chest â: â forc â Standard Libs â Sway Standards â LSP
0
0
13
Simply deploy as normal and itâs handled atomically. No rework, no bugs, just a smoother developer experience. Developing in Sway: â
 Reduces overhead â
 Minimizes bugs â
 Makes smart contracts easy
1
0
1
In our 400KB example, Forc splits it into: 4 contracts (100KB each) + 1 loader contract
1
0
1
Sway? Itâs a game-changer. Hit the 100KB limit? No sweat. Forc automatically splits your oversized contract into multiple âblobsâ and uses a loader contract to stitch them together. Your contract works as just by calling the loader contract. Zero rewriting needed!
1
0
0
In Solidity, hitting the 24KB limit is a headache. Youâre forced to use techniques to work around this limitation like: đ Use proxy patterns đȘ Split logic into multiple contracts đ§Â Replace modifiers with functions Then, rewrite all your tests to avoid new bugs. Terrible
1
0
0
Why are there contract size limits? Every node has to store and process contract code. Limits prevent: đ«Â DDoS attacks đ Poor network performance đŸÂ Blockchain bloat Limits also push devs to write modular, efficient code. (Spurious Dragonâs EIP-170 set this standard in
1
0
0
Solidity caps contracts at 24KB. Sway? 100KB. But what happens when your contract is too big? Letâs dive into how Sway solves this painlessly compared to Solidity đ§”
2
0
1
đ Below are additional resources. The Sway standard library is a great reference for more complex examples on how to build a library, and the full FuelVM instruction set includes most of the instructions youâd find in the EVM plus more! âĄïžÂ Sway standard library examples:
0
0
0
Want to return multiple values? You can modify a tuple within the assembly block:
1
0
1
đ Understanding the asm Block: This simply uses the add instruction to add one to register r1 and stores the result in register r2, then returns it. The return register is specified at the end, after all assembly instructions. It consists of the register name and optional
1
0
0
â
Just like Solidity, Sway also has `assembly` blocks: But the main user facing form is `asm {}`.
1
0
0
đ§ Why use Assembly? â Gas Optimization: Writing logic directly in asm blocks reduces gas costs by avoiding high-level abstractions â Low-Level Control: Direct access to FuelVM instruction set perfect for library authors or power users who need custom memory management or
1
0
0
Assembly in Sway is optional, but it's there when you need to squeeze out every bit of performance and take direct control of the FuelVM. Let's break it down đ§”
1
0
2
Sway is an open source language, purpose-built for blockchain development. Written in Rust, it combines the best features of Solidity and Rust to enable secure, high performance smart contracts. Come explore what Sway has to offer https://t.co/8XJM3GEDQ4
1
1
7