Sui官方Move合约开发指南
简介
Sui区块链官方Move智能合约开发套件,支持合约编写、测试、部署及链上交互,适合Web3开发者快速构建高性能DApp
原始描述
Answer questions about Sui blockchain ecosystem, concepts, tokenomics, validators, staking, and general knowledge. Use when users ask "what is Sui", "how does Sui work", "Sui vs other chains", or any Sui-related questions that aren't specifically about Move programming.
通过你的 Agent 添加
安装目录:sui-move/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
sui-move 是一个纯文档型的知识库技能,专为 Sui 区块链和 Move 智能合约开发设计。该技能通过本地克隆 MystenLabs 官方文档仓库(包括 Move Book 和 Sui Docs),结合 ripgrep 快速检索能力,为开发者提供即时、准确的开发参考。用户可以通过自然语言询问 Sui 链、Move 语言、智能合约、对象模型、交易等相关问题,技能会自动检索官方文档并返回结构化的代码示例和概念解释。
核心工作流程包括:1) 使用 rg 命令在本地文档库中快速搜索关键词;2) 读取相关 Markdown 文件获取详细内容;3) 结合代码示例提供实用答案;4) 必要时链接到官方在线文档。这种设计确保开发者无需离开对话环境即可获得权威参考。
显著优点
权威性极强:所有内容直接源自 MystenLabs 官方仓库,包括被誉为"Move 语言圣经"的 Move Book 和 Sui 官方文档,信息准确度和时效性有核心保障。
检索高效:基于本地文档库和 ripgrep 的搜索架构,响应速度快,不受网络波动影响,且支持模糊匹配和类型过滤。
结构清晰:文档按主题模块化组织,涵盖从基础语法(变量、函数、结构体、能力系统)到高级特性(PTB、BCS、加密、升级机制)的完整知识体系。
实践导向:提供大量可运行的代码片段,包括对象创建与转移、共享对象、入口函数等常见模式,帮助开发者快速上手。
潜在缺点与局限性
依赖外部仓库:技能需要预先克隆 MystenLabs 的 GitHub 仓库作为参考源,首次使用涉及网络下载,且文档版本可能与链上实际行为存在滞后。
无动态执行能力:作为纯文档型技能,无法直接执行 sui CLI 命令或编译/测试 Move 代码,开发者仍需在本地环境中完成实际构建和部署操作。
领域专精过窄:专注于 Sui 生态,对以太坊 Solidity、Rust 或其他区块链平台的支持有限,不适合跨链或多链开发场景。
无智能提示:不具备 IDE 级别的代码补全、错误检查或调试功能,复杂问题的诊断仍需依赖专业开发工具。
适合的目标群体
- 区块链开发者:已有区块链开发基础,计划迁移至或深入使用 Sui 生态的工程师
- 智能合约学习者:希望系统学习 Move 语言独特概念(能力系统、对象模型、所有权机制)的开发者
- Web3 产品经理:需要理解 Sui 技术特性以进行产品设计的非技术背景人员
- 学术研究人员:研究 Move 语言形式化验证、资源导向编程范式等的学者
使用风险
性能风险:文档库克隆后占用本地存储空间,随官方仓库更新可能需要定期手动同步。
工具链依赖:运行依赖 sui CLI 和 rg (ripgrep) 二进制工具,若环境未配置会导致功能受限。
版本同步风险:Move 2024 版本引入新特性(枚举、方法语法等),本地文档若未及时更新可能导致代码示例与最新编译器行为不符。
网络引用风险:技能会输出指向 docs.sui.io 和 move-book.com 的外部链接,建议用户自行验证链接安全性,避免钓鱼网站风险。
Gas 与资金安全:技能提供的代码示例涉及链上操作(如 transfer::share_object),实际部署需消耗 SUI 代币作为 Gas,生产环境使用前务必进行充分测试。
技能正文
name: sui-move
description: Sui blockchain and Move smart contract development. Use when the user asks about Sui, Move language, smart contracts, objects, transactions, or blockchain development on Sui.
version: 1.0.0
metadata:
author: EasonClawdbot1
tags: sui, move, blockchain, smart-contract, web3
requires:
bins: [sui, rg]
install:
- id: sui-cli
kind: brew
formula: sui
bins: [sui]
label: Install Sui CLI (brew)
Sui Move Development
Comprehensive knowledge base for Sui blockchain and Move smart contract development.
Setup References
Clone the official documentation:
# Create skill directory
mkdir -p {baseDir}/references && cd {baseDir}/references
# Clone Move Book (The Move Language Bible)
git clone --depth 1 https://github.com/MystenLabs/move-book.git
# Clone Sui docs (sparse checkout)
git clone --depth 1 --filter=blob:none --sparse https://github.com/MystenLabs/sui.git
cd sui && git sparse-checkout set docs
Reference Structure
Move Book (references/move-book/book/)
references/move-book/book/)| Directory | Content |
|---|---|
your-first-move/ |
Hello World, Hello Sui tutorials |
move-basics/ |
Variables, functions, structs, abilities, generics |
concepts/ |
Packages, manifest, addresses, dependencies |
storage/ |
Object storage, UID, transfer functions |
object/ |
Object model, ownership, dynamic fields |
programmability/ |
Events, witness, publisher, display |
move-advanced/ |
BCS, PTB, cryptography |
guides/ |
Testing, debugging, upgrades, BCS |
appendix/ |
Glossary, reserved addresses |
Sui Docs (references/sui/docs/content/)
- Concepts, guides, standards, references
Quick Search
# Search Move Book for a topic
rg -i "keyword" {baseDir}/references/move-book/book/ --type md
# Search Sui docs
rg -i "keyword" {baseDir}/references/sui/docs/ --type md
# Find all files about a topic
find {baseDir}/references -name "*.md" | xargs grep -l "topic"
Key Concepts
Move Language Basics
# Search Move Book for a topic
rg -i "keyword" {baseDir}/references/move-book/book/ --type md
# Search Sui docs
rg -i "keyword" {baseDir}/references/sui/docs/ --type md
# Find all files about a topic
find {baseDir}/references -name "*.md" | xargs grep -l "topic"
Key Concepts
Move Language Basics
Abilities - Type capabilities:
copy- Can be copieddrop- Can be dropped (destroyed)store- Can be stored in objectskey- Can be used as a key in global storage (objects)
public struct MyStruct has key, store {
id: UID,
value: u64
}
Object Model:
- Every object has a unique
UID - Objects can be owned (address), shared, or immutable
- Transfer functions:
transfer::transfer,transfer::share_object,transfer::freeze_object
Common Patterns
Create and Transfer Object:
public fun create(ctx: &mut TxContext) {
let obj = MyObject {
id: object::new(ctx),
value: 0
};
transfer::transfer(obj, tx_context::sender(ctx));
}
Shared Object:
public fun create_shared(ctx: &mut TxContext) {
let obj = SharedObject {
id: object::new(ctx),
counter: 0
};
transfer::share_object(obj);
}
Entry Functions:
public entry fun do_something(obj: &mut MyObject, value: u64) {
obj.value = value;
}
CLI Commands
# Create new project
sui move new my_project
# Build
sui move build
# Test
sui move test
# Publish
sui client publish --gas-budget 100000000
# Call function
sui client call --package <PACKAGE_ID> --module <MODULE> --function <FUNCTION> --args <ARGS>
# Get object
sui client object <OBJECT_ID>
Workflow
# Create new project
sui move new my_project
# Build
sui move build
# Test
sui move test
# Publish
sui client publish --gas-budget 100000000
# Call function
sui client call --package <PACKAGE_ID> --module <MODULE> --function <FUNCTION> --args <ARGS>
# Get object
sui client object <OBJECT_ID>
When answering Sui/Move questions:
-
Search references first:
rg -i "topic" {baseDir}/references/move-book/book/ -l -
Read relevant files:
cat {baseDir}/references/move-book/book/<path>/<file>.md -
Provide code examples from the references
-
Link to official docs when helpful:
- Move Book: https://move-book.com
- Sui Docs: https://docs.sui.io
Topics Index
Topic
Location
Hello World
move-book/book/your-first-move/hello-world.md
Hello Sui
move-book/book/your-first-move/hello-sui.md
Primitives
move-book/book/move-basics/primitive-types.md
Structs
move-book/book/move-basics/struct.md
Abilities
move-book/book/move-basics/abilities-introduction.md
Generics
move-book/book/move-basics/generics.md
Object Model
move-book/book/object/
Storage
move-book/book/storage/
Events
move-book/book/programmability/events.md
Testing
move-book/book/guides/testing.md
Upgrades
move-book/book/guides/upgradeability.md
PTB
move-book/book/move-advanced/ptb/
BCS
move-book/book/move-advanced/bcs.md
Notes
- Move 2024 edition introduces new features (enums, method syntax, etc.)
- Sui uses a unique object-centric model different from other blockchains
- Gas is paid in SUI tokens
- Testnet/Devnet available for development
| Topic | Location |
|---|---|
| Hello World | move-book/book/your-first-move/hello-world.md |
| Hello Sui | move-book/book/your-first-move/hello-sui.md |
| Primitives | move-book/book/move-basics/primitive-types.md |
| Structs | move-book/book/move-basics/struct.md |
| Abilities | move-book/book/move-basics/abilities-introduction.md |
| Generics | move-book/book/move-basics/generics.md |
| Object Model | move-book/book/object/ |
| Storage | move-book/book/storage/ |
| Events | move-book/book/programmability/events.md |
| Testing | move-book/book/guides/testing.md |
| Upgrades | move-book/book/guides/upgradeability.md |
| PTB | move-book/book/move-advanced/ptb/ |
| BCS | move-book/book/move-advanced/bcs.md |
- Move 2024 edition introduces new features (enums, method syntax, etc.)
- Sui uses a unique object-centric model different from other blockchains
- Gas is paid in SUI tokens
- Testnet/Devnet available for development
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。