← ClaudeAtlas

sui-move-syntaxlisted

Move language syntax — module layout, imports, mutability, visibility, method syntax, enums, macros, and comments.
widnyana/eyay-toolkits · ★ 4 · Web & Frontend · score 77
Install: claude install-skill widnyana/eyay-toolkits
## 1. Module Layout Use the new single-line module declaration without braces: ```move // ✅ module my_package::my_module; // ❌ Legacy — do not use module my_package::my_module { ... } ``` Standard section order within a module: 1. `use` imports 2. Constants (`const`) 3. Structs / Enums 4. `fun init` (if needed) 5. Public functions 6. `public(package)` functions 7. Private functions 8. Test module (`#[test_only]`) Use `=== Section Title ===` comments to delimit sections for readability. ### `use` import rules Don't use a lone `{Self}` — just import the module directly: ```move // ✅ use my_package::my_module; // ❌ Redundant braces use my_package::my_module::{Self}; ``` When importing both the module and members, group them with `Self`: ```move // ✅ use sui::coin::{Self, Coin}; // ❌ Separate imports use sui::coin; use sui::coin::Coin; ``` --- ## 2. Mutability — `mut` is Required All variables that are reassigned or mutably borrowed must be declared `let mut`: ```move // ✅ let mut pool = Pool { id: object::new(ctx), ... }; let mut balance = balance::zero<SUI>(); // ❌ Legacy let pool = Pool { id: object::new(ctx), ... }; ``` Function parameters that are mutably borrowed must also be `mut`: ```move public fun deposit(mut pool: Pool, coin: Coin<SUI>): Pool { ... } ``` --- ## 3. Visibility | Keyword | Scope | | ----------------- | ---------------------------------------------- | | `public` | Calla