← ClaudeAtlas

sui-move-stdliblisted

Common Sui Move standard library patterns — strings, Coin/Balance, Option, addresses, UID, TxContext, vectors, and struct unpacking.
widnyana/eyay-toolkits · ★ 4 · Web & Frontend · score 77
Install: claude install-skill widnyana/eyay-toolkits
## 1. Common Standard Library Patterns ```move // Strings — use method syntax, don't import utf8 let s: String = b"hello".to_string(); let ascii: ascii::String = b"hello".to_ascii_string(); // Coin and Balance use sui::coin::{Self, Coin}; use sui::balance::{Self, Balance}; let balance: Balance<SUI> = coin.into_balance(); let coin: Coin<SUI> = balance.into_coin(ctx); // ✅ method syntax let amount: u64 = coin.value(); // Split a payment let exact = payment.split(amount, ctx); // ✅ let exact = payment.balance_mut().split(amount); // ✅ avoids ctx // Consuming values without `drop` — the @0x0 burn pattern // // Move's linear type system requires every non-`drop` value to be // explicitly consumed. The `_` prefix only suppresses warnings for values // that *do* have `drop` — it won't help for Balance<T>, Coin<T>, or your // own structs that lack `drop`. // // To permanently destroy any `key + store` object, transfer it to @0x0 // (an address no one controls, equivalent to Solidity's address(0)): transfer::public_transfer(my_obj, @0x0); // ✅ permanent burn // // Balance<T> has neither `drop` nor `key`, so it cannot be transferred // directly, and `balance::destroy_zero` only works on empty balances. // Wrap it in a Coin first: // // let _locked = supply.increase_supply(MINIMUM_LIQUIDITY); // ❌ compile error // let locked = supply.increase_supply(MINIMUM_LIQUIDITY).into_coin(ctx); transfer::public_transfer(locked, @0x0); // ✅ burns the minimum liquidity //