Skip to content
Back to skills

Sui Move Stdlib

ASecurity

Common Sui Move standard library patterns — strings, Coin/Balance, Option, addresses, UID, TxContext, vectors, and struct unpacking.

  • 7 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 26, 2026
developmenttesting

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add widnyana/eyay-toolkits --skill sui-move-stdlib --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sui Move Stdlib?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sui Move Stdlib
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/widnyana-sui-move-stdlib/badge)](https://www.skillsdirectory.com/skills/widnyana-sui-move-stdlib)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sui-move-stdlib
description: Common Sui Move standard library patterns — strings, Coin/Balance, Option, addresses, UID, TxContext, vectors, and struct unpacking.
---

## 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
//
// Hot potatoes (structs with no abilities at all) cannot use this pattern —
// they must be destructured and each field consumed individually.

// Option
let opt: Option<u64> = option::some(42);
let val = opt.destroy_or!(default_value);      // ✅ macro form
let val = opt.borrow();

// Address and IDs
let id: ID = object::id(&my_obj);
let addr: address = id.to_address();

// UID deletion
id.delete();                                   // ✅
// object::delete(id);                         // ❌ verbose

// TxContext sender
ctx.sender()                                   // ✅
// tx_context::sender(ctx)                     // ❌ verbose

// Vector literals and index syntax
let mut v = vector[1, 2, 3];                   // ✅ literal
let first = v[0];                              // ✅ index syntax
assert!(v.length() == 3);                      // ✅ method syntax
// let mut v = vector::empty();               // ❌ verbose
// vector::push_back(&mut v, 1);              // ❌ verbose

// Struct unpack — use .. to ignore fields you don't need
let MyStruct { id, .. } = value;               // ✅
// let MyStruct { id, field_a: _, field_b: _ } = value; // ❌ verbose
```

---

## Routing

| Task                                             | Load                    |
| ------------------------------------------------ | ----------------------- |
| Abilities required by stdlib types               | `sui-move-object`       |
| Method syntax for stdlib method calls            | `sui-move-syntax`       |
| Error handling with assert! and error constants  | `sui-move-patterns`     |
| Package config, building, testing                | `sui-move-setup`        |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.