sui-sdks

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sui SDKs

Sui SDKs

MCP tool: When available in your environment, also query the Sui documentation MCP server (
https://sui.mcp.kapa.ai
) for up-to-date answers. Use it for verification and for details not covered by these reference files.
Most AI agents give confusing, outdated, or cross-wired answers about Sui SDKs. This skill fixes the three most common failure modes:
  1. Recommending a community SDK as if it were official. Only two SDKs are maintained by Mysten Labs: TypeScript (
    @mysten/sui
    ) and Rust (
    sui-rust-sdk
    family of crates). Everything else is community-maintained.
  2. Mixing up TypeScript SDK generations. The old
    @mysten/sui.js
    package was renamed to
    @mysten/sui
    at v1.0. The v2 client API (
    client.core.*
    ,
    include
    instead of
    show*
    ,
    SuiGrpcClient
    replacing
    SuiClient
    ) is distinct from v1.
  3. Not using the installed LLM docs. Every
    @mysten/*
    package ships
    docs/llms-index.md
    + topic-specific markdown files to
    node_modules
    . Agents should read those before answering; they are guaranteed to match the installed version.
All patterns in this skill are derived from:
If unsure about any specific API in any SDK, fetch from the relevant doc page — do not extrapolate from a different SDK's surface.

MCP工具: 若你的环境支持,也可查询Sui文档MCP服务器(
https://sui.mcp.kapa.ai
)获取最新答案。用于验证信息及补充本参考文档未覆盖的细节。
大多数AI Agent在回答Sui SDK相关问题时,给出的答案混乱、过时或混淆概念。本技能解决了三个最常见的问题:
  1. 将社区SDK当作官方SDK推荐:只有两个SDK由Mysten Labs官方维护:TypeScript版本(
    @mysten/sui
    )和Rust版本(
    sui-rust-sdk
    系列crate)。其余所有SDK均为社区维护。
  2. 混淆TypeScript SDK的版本代际:旧版
    @mysten/sui.js
    包在v1.0时更名为
    @mysten/sui
    。v2客户端API(
    client.core.*
    、使用
    include
    替代
    show*
    SuiGrpcClient
    替代
    SuiClient
    )与v1版本完全不同。
  3. 未使用已安装的LLM文档:每个
    @mysten/*
    包都会将
    docs/llms-index.md
    及主题相关的markdown文件发布到
    node_modules
    目录中。Agent在回答前应先阅读这些文档,它们能保证与已安装版本完全匹配。
本技能中的所有模式均源自:
若对任意SDK中的特定API不确定,请从对应文档页面获取信息——不要从其他SDK的接口推断。

Reference files

参考文档

typescript — TypeScript SDK (
@mysten/sui
v2)

typescript — TypeScript SDK(
@mysten/sui
v2)

Path:
typescript.md
Load when: writing, reviewing, or migrating TypeScript/JavaScript code that imports
@mysten/sui
, constructing PTBs in TS, choosing between
SuiGrpcClient
/
SuiJsonRpcClient
/
SuiGraphQLClient
, using the v2 Core API, or migrating from SDK v1 (
@mysten/sui.js
). Covers: install, imports, client classes and when to use each, v2 Core API, PTB construction, pure/object inputs,
coinWithBalance
intent, execution & status checking,
waitForTransaction
, keypairs, offline building, sponsored transactions, v1→v2 migration table,
$extend
pattern for kiosk/suins/deepbook/walrus/seal/zksend.
路径:
typescript.md
加载时机: 编写、审查或迁移导入
@mysten/sui
的TypeScript/JavaScript代码,在TS中构建PTB,选择
SuiGrpcClient
/
SuiJsonRpcClient
/
SuiGraphQLClient
,使用v2 Core API,或从SDK v1(
@mysten/sui.js
)迁移时。 涵盖内容: 安装、导入、客户端类及适用场景、v2 Core API、PTB构建、纯输入/对象输入、
coinWithBalance
意图、执行与状态检查、
waitForTransaction
、密钥对、离线构建、赞助交易、v1→v2迁移表、用于kiosk/suins/deepbook/walrus/seal/zksend的
$extend
模式。

rust — Rust SDK (
sui-*
crates)

rust — Rust SDK(
sui-*
crates)

Path:
rust.md
Load when: writing Rust code that interacts with Sui — CLI tools, backend services, validators, indexers. Also when choosing between the new modular crates and the legacy in-monorepo
sui-sdk
crate. Covers: the five crates (
sui-sdk-types
,
sui-crypto
,
sui-rpc
,
sui-graphql
,
sui-transaction-builder
),
TransactionBuilder
API with an end-to-end example, signing via
sui-crypto
, gRPC client from
sui-rpc
, relationship to the legacy
sui-sdk
crate, and the "intents" feature flag (high-level
Coin
/
Balance
intents).
路径:
rust.md
加载时机: 编写与Sui交互的Rust代码——CLI工具、后端服务、验证器、索引器。以及在新模块化crate与旧版单仓库
sui-sdk
crate之间做选择时。 涵盖内容: 五个核心crate(
sui-sdk-types
sui-crypto
sui-rpc
sui-graphql
sui-transaction-builder
)、带端到端示例的
TransactionBuilder
API、通过
sui-crypto
签名、
sui-rpc
中的gRPC客户端、与旧版
sui-sdk
crate的关系,以及“意图”功能标志(高级
Coin
/
Balance
意图)。

community — Community SDKs (Python, Go, Dart, Kotlin, Swift, Vue)

community — 社区SDK(Python、Go、Dart、Kotlin、Swift、Vue)

Path:
community.md
Load when: a user asks about or is using a non-TS-non-Rust SDK. Also when assessing risk for a language choice (maintainer responsiveness, feature gaps vs official SDKs). Covers: for each community SDK — repo, maintainer, install, what's supported/not, caveats, and a recommendation on whether to use it or call the Rust/TS SDK from an FFI wrapper instead.
路径:
community.md
加载时机: 用户询问或使用非TS非Rust的SDK时。以及评估语言选择的风险(维护者响应速度、与官方SDK的功能差距)时。 涵盖内容: 每个社区SDK的仓库地址、维护者、安装方法、支持/不支持的功能、注意事项,以及是否使用该SDK或通过FFI包装器调用Rust/TS SDK的建议。

mapping — Cross-SDK operation mapping

mapping — 跨SDK操作映射

Path:
mapping.md
Load when: porting code from one SDK to another, writing a polyglot reference, or answering "how do I do X in SDK Y". Covers: side-by-side tables mapping the 10-or-so core Sui operations (build PTB, split gas, moveCall, transfer, sign & execute, wait, query object / owned objects / balance, dry-run) across the TS and Rust SDKs, with syntactic parallels.
路径:
mapping.md
加载时机: 在不同SDK间移植代码、编写多语言参考文档,或回答“如何在SDK Y中实现X操作”时。 涵盖内容: 并列表格展示10余项核心Sui操作(构建PTB、拆分Gas、moveCall、转账、签名与执行、等待、查询对象/自有对象/余额、试运行)在TS和Rust SDK中的对应实现,以及语法相似性。

llm-docs — Using bundled docs from node_modules

llm-docs — 使用node_modules中的捆绑文档

Path:
llm-docs.md
Load when: the agent needs authoritative, version-matched TypeScript API docs before writing code. Always check
node_modules/@mysten/*/docs/llms-index.md
first if it exists. Covers: the
docs/llms-index.md
convention, which
@mysten/*
packages ship it, how to read the index and target pages, how to wire it into
AGENTS.md
/
CLAUDE.md
for a project.
路径:
llm-docs.md
加载时机: Agent在编写代码前需要权威、版本匹配的TypeScript API文档时。若存在
node_modules/@mysten/*/docs/llms-index.md
,请优先查看。 涵盖内容:
docs/llms-index.md
规范、哪些
@mysten/*
包包含该文档、如何阅读索引及目标页面、如何将其集成到项目的
AGENTS.md
/
CLAUDE.md
中。

Routing guide

路由指南

TaskLoad
"Which SDK should I use?"(this file) + mapping
Writing TS/JS code against Suitypescript + llm-docs
Writing Rust code against Suirust
Using pysui / ksui / suikit / sui-go / mofalabs/suicommunity
User mentions Go / Python / Dart / Kotlin / Swift / Vue (even casually, e.g. "my team uses Go")community (always — language constraint trumps perf recommendations)
Porting between languagesmapping + (target SDK file)
Migrating from
@mysten/sui.js
/ SDK v1
typescript
Frontend / React integrationroute to
frontend-apps
skill first (covers React hooks, wallet connection, query patterns), then typescript here for
Transaction
construction
PTB semantics deep diveroute to
ptbs
skill, then language-specific file here
Data access patterns (gRPC vs GraphQL vs indexer)route to
accessing-data
skill
Full project setupall reference files (or the SDK-specific one + llm-docs)
Code reviewall reference files
任务加载文档
"我应该用哪个SDK?"(本文档)+ mapping
编写针对Sui的TS/JS代码typescript + llm-docs
编写针对Sui的Rust代码rust
使用pysui / ksui / suikit / sui-go / mofalabs/suicommunity
用户提及Go / Python / Dart / Kotlin / Swift / Vue(即使是随口提及,例如“我的团队使用Go”)community(始终优先——语言约束优于性能建议)
在不同语言间移植代码mapping + (目标SDK文档)
@mysten/sui.js
/ SDK v1迁移
typescript
前端/React集成先路由到
frontend-apps
技能(涵盖React hooks、钱包连接、查询模式),再使用本文档中的typescript部分处理
Transaction
构建
PTB语义深入解析路由到
ptbs
技能,再使用本文档中的对应语言特定文档
数据访问模式(gRPC vs GraphQL vs 索引器)路由到
accessing-data
技能
完整项目搭建所有参考文档(或特定SDK文档 + llm-docs)
代码审查所有参考文档

Skill Content

技能内容

Key concepts

核心概念

  • Two officially-supported SDKs. TypeScript (
    @mysten/sui
    ) and Rust (
    sui-rust-sdk
    crates). Both are maintained by Mysten Labs and updated alongside protocol changes. For performance-critical paths in non-Rust languages,
    sui-rust-sdk
    can be called via FFI (Foreign Function Interface) from Python, Go, Swift, etc., giving those languages access to the official SDK without relying on community wrappers.
  • Everything else is community. Python (
    pysui
    ), Go (
    block-vision/sui-go-sdk
    ), Dart (
    mofalabs/sui
    ), Kotlin (
    mcxross/ksui
    ), Swift (
    opendive/suikit
    ), Vue (
    SuiFansCN/suiue
    ). They typically lag protocol updates and feature coverage varies. Treat them as best-effort.
  • The TS SDK has two client generations. v1 used
    SuiClient
    +
    @mysten/sui.js
    . v2 uses
    SuiGrpcClient
    /
    SuiJsonRpcClient
    /
    SuiGraphQLClient
    from
    @mysten/sui
    . JSON-RPC is deprecated; gRPC is recommended for new code.
  • The Rust SDK has two generations. The new modular crates (
    sui-sdk-types
    ,
    sui-crypto
    ,
    sui-rpc
    ,
    sui-transaction-builder
    ) are the recommended surface. The "legacy Rust SDK" is the monolithic
    sui-sdk
    crate in the sui monorepo; it supports JSON-RPC with forward/backward compatibility and is still used by many existing projects, but is not the recommended target for new code.
  • Every
    @mysten/*
    package ships LLM-ready docs.
    Look for
    node_modules/@mysten/sui/docs/llms-index.md
    and follow its pointers before asking the user to clarify APIs. Matches the installed version exactly.
  • Frameworks on top of SDKs.
    @mysten/dapp-kit-react
    (React wallet integration;
    @mysten/dapp-kit-core
    for Vue/vanilla/Svelte/Web Components),
    @mysten/kiosk
    ,
    @mysten/suins
    ,
    @mysten/deepbook-v3
    ,
    @mysten/walrus
    ,
    @mysten/seal
    ,
    @mysten/zksend
    ,
    @mysten/enoki
    — all are thin layers over
    @mysten/sui
    . The Mysten extensions integrate via the v2
    client.$extend(...)
    pattern; dApp Kit does not (it's a React framework, not a client extension — see
    frontend-apps
    skill). The bare
    @mysten/dapp-kit
    package name is the deprecated JSON-RPC-only predecessor.
  • 两个官方支持的SDK:TypeScript(
    @mysten/sui
    )和Rust(
    sui-rust-sdk
    crates)。两者均由Mysten Labs维护,并随协议更新同步迭代。对于非Rust语言中的性能关键路径,可通过FFI(Foreign Function Interface)调用
    sui-rust-sdk
    ,让这些语言无需依赖社区包装器即可访问官方SDK。
  • 其余均为社区维护:Python(
    pysui
    )、Go(
    block-vision/sui-go-sdk
    )、Dart(
    mofalabs/sui
    )、Kotlin(
    mcxross/ksui
    )、Swift(
    opendive/suikit
    )、Vue(
    SuiFansCN/suiue
    )。这些SDK通常滞后于协议更新,功能覆盖范围各不相同。请将它们视为尽力维护的资源。
  • TS SDK有两代客户端:v1版本使用
    SuiClient
    +
    @mysten/sui.js
    。v2版本使用
    @mysten/sui
    中的
    SuiGrpcClient
    /
    SuiJsonRpcClient
    /
    SuiGraphQLClient
    。JSON-RPC已被弃用;新项目推荐使用gRPC。
  • Rust SDK有两代版本:新的模块化crate(
    sui-sdk-types
    sui-crypto
    sui-rpc
    sui-transaction-builder
    )是推荐使用的版本。“旧版Rust SDK”是sui单仓库中的单片
    sui-sdk
    crate;它支持JSON-RPC的向前/向后兼容性,仍被许多现有项目使用,但不推荐用于新项目。
  • 每个
    @mysten/*
    包都附带LLM友好文档
    :查找
    node_modules/@mysten/sui/docs/llms-index.md
    并遵循其指引,再请求用户澄清API细节。这些文档与已安装版本完全匹配。
  • 基于SDK构建的框架
    @mysten/dapp-kit-react
    (React钱包集成;
    @mysten/dapp-kit-core
    适用于Vue/原生JS/Svelte/Web Components)、
    @mysten/kiosk
    @mysten/suins
    @mysten/deepbook-v3
    @mysten/walrus
    @mysten/seal
    @mysten/zksend
    @mysten/enoki
    ——所有这些都是基于
    @mysten/sui
    的轻量级封装。Mysten扩展通过v2的
    client.$extend(...)
    模式集成;dApp Kit则不采用此模式(它是React框架,而非客户端扩展——详见
    frontend-apps
    技能)。
    @mysten/dapp-kit
    包名是已弃用的仅支持JSON-RPC的旧版本。

Rules

规则

  1. Default to TypeScript or Rust, but respect language constraints. For any new Sui project, recommend TypeScript (
    @mysten/sui
    ) or Rust (
    sui-rust-sdk
    crates) — unless the user has named a language (Go, Python, Dart, Kotlin, Swift, Vue) or said "my team uses X". Then
    community.md
    is the load: name the canonical community SDK (
    block-vision/sui-go-sdk
    for Go,
    pysui
    for Python, etc.), flag the staleness risk, and offer FFI-to-Rust as a fallback. Do not recommend TypeScript or Rust as a replacement language when the user has stated their team's language. For example, if the user says "my team uses Go", do not suggest rewriting in TypeScript — recommend the Go community SDK and/or Rust via FFI.
  2. For TypeScript, always use
    @mysten/sui
    , never
    @mysten/sui.js
    .
    The
    .js
    -suffixed package is frozen at v1 and will not receive updates. Legacy code using it should be migrated.
  3. For TypeScript v2, use
    SuiGrpcClient
    by default.
    SuiJsonRpcClient
    exists for legacy compatibility;
    SuiGraphQLClient
    is for specialized query flows. See
    typescript.md
    for the decision.
  4. For Rust, prefer
    sui-rust-sdk
    crates over the legacy monorepo
    sui-sdk
    .
    Import
    sui-transaction-builder
    ,
    sui-sdk-types
    ,
    sui-crypto
    ,
    sui-rpc
    individually — pay only for what you use.
  5. Check
    node_modules/@mysten/*/docs/llms-index.md
    before writing TS code.
    If the project has
    @mysten/sui
    installed, those docs are the authoritative, version-matched source. Read the index, then the targeted page.
  6. Do not mix v1 and v2 TS patterns. Code that uses
    SuiClient
    ,
    TransactionBlock
    ,
    getFullnodeUrl
    ,
    options: { showEffects }
    ,
    signAndExecuteTransactionBlock
    , or
    result.effects?.status?.status
    is v1. Migrate wholesale or keep everything on v1 — a half-migrated file is a bug surface.
  7. Community SDK caveat is mandatory. When recommending or using a community SDK, mention that it's community-maintained and may lag protocol updates. Check the repo's last commit and latest Sui version support before relying on it.
  8. Frameworks integrate via
    $extend()
    in v2.
    client.$extend(suins(), deepbook({ address }))
    is the v2 pattern. Do not instantiate
    SuinsClient
    or
    DeepBookClient
    directly — that's the v1 style.
  9. Route frontend questions to the
    frontend-apps
    skill.
    When the user asks about React hooks, wallet connection, or dApp Kit query patterns, explicitly direct them to the
    frontend-apps
    skill for hook-level details. This skill covers SDK selection and
    Transaction
    construction only.
  10. Cite the docs when unsure. Official TS SDK docs live at
    sdk.mystenlabs.com
    . The inventory list lives at
    docs.sui.io/references/sui-sdks
    . Rust SDK docs live on
    docs.rs
    (per-crate) and
    mystenlabs.github.io/sui-rust-sdk/<crate_name>/
    (e.g.,
    /sui_transaction_builder/
    ).
  1. 默认推荐TypeScript或Rust,但需尊重语言约束:对于任何新的Sui项目,推荐TypeScript(
    @mysten/sui
    )或Rust(
    sui-rust-sdk
    crates)——除非用户指定了某一语言(Go、Python、Dart、Kotlin、Swift、Vue)或表示“我的团队使用X语言”。此时应加载
    community.md
    :指明标准社区SDK(Go对应
    block-vision/sui-go-sdk
    ,Python对应
    pysui
    等),标注过时风险,并提供“通过FFI调用Rust”作为备选方案。当用户明确说明团队使用的语言时,不要推荐TypeScript或Rust作为替代语言。例如,如果用户说“我的团队使用Go”,不要建议重写为TypeScript——应推荐Go社区SDK和/或通过FFI调用Rust。
  2. 对于TypeScript,始终使用
    @mysten/sui
    ,而非
    @mysten/sui.js
    :带
    .js
    后缀的包已在v1版本冻结,不会再收到更新。使用该包的旧代码应进行迁移。
  3. 对于TypeScript v2,默认使用
    SuiGrpcClient
    SuiJsonRpcClient
    仅用于旧版兼容;
    SuiGraphQLClient
    适用于特定查询流程。详见
    typescript.md
    中的决策指引。
  4. 对于Rust,优先选择
    sui-rust-sdk
    crates而非旧版单仓库
    sui-sdk
    :单独导入
    sui-transaction-builder
    sui-sdk-types
    sui-crypto
    sui-rpc
    ——按需引入,减少依赖体积。
  5. 编写TS代码前先检查
    node_modules/@mysten/*/docs/llms-index.md
    :若项目已安装
    @mysten/sui
    ,这些文档是权威的、版本匹配的来源。先阅读索引,再查看目标页面。
  6. 不要混合使用TS的v1和v2模式:使用
    SuiClient
    TransactionBlock
    getFullnodeUrl
    options: { showEffects }
    signAndExecuteTransactionBlock
    result.effects?.status?.status
    的代码属于v1版本。要么完全迁移到v2,要么继续使用v1——半迁移的代码会成为bug来源。
  7. 必须标注社区SDK的注意事项:当推荐或使用社区SDK时,需提及它是社区维护的,可能滞后于协议更新。依赖前请检查仓库的最后提交时间及支持的最新Sui版本。
  8. 框架在v2中通过
    $extend()
    集成
    :v2的模式是
    client.$extend(suins(), deepbook({ address }))
    。不要直接实例化
    SuinsClient
    DeepBookClient
    ——这是v1的风格。
  9. 前端问题路由到
    frontend-apps
    技能
    :当用户询问React hooks、钱包连接或dApp Kit查询模式时,明确引导他们查看
    frontend-apps
    技能获取钩子层面的细节。本技能仅涵盖SDK选型和
    Transaction
    构建。
  10. 不确定时引用官方文档:官方TS SDK文档位于
    sdk.mystenlabs.com
    。SDK清单位于
    docs.sui.io/references/sui-sdks
    。Rust SDK文档位于
    docs.rs
    (按crate划分)和
    mystenlabs.github.io/sui-rust-sdk/<crate_name>/
    (例如
    /sui_transaction_builder/
    )。

Common mistakes

常见错误

  • Calling a community SDK "the Python SDK" or "the Go SDK" as if official. There is no official Python or Go SDK. Name the specific package (
    pysui
    ,
    block-vision/sui-go-sdk
    ) and flag it as community.
  • Telling users
    SuiClient
    is the recommended client.
    That was v1. v2 uses
    SuiGrpcClient
    (or
    SuiJsonRpcClient
    for legacy flows).
  • Recommending
    @mysten/sui.js
    .
    Deprecated package name. Always
    @mysten/sui
    .
  • Confusing the two Rust SDKs. The new
    sui-rust-sdk
    crates (on
    crates.io
    as separate crates like
    sui-sdk-types
    /
    sui-transaction-builder
    /
    sui-rpc
    ) are distinct from the legacy
    sui-sdk
    crate in the sui monorepo. New code should use the former.
  • Fetching TS docs from the web when they're installed locally. If the project has
    @mysten/sui
    installed, read
    node_modules/@mysten/sui/docs/llms-index.md
    instead — it matches the installed version.
  • Hardcoding a specific SDK version. SDK APIs evolve. Prefer "install the latest
    @mysten/sui
    " and then consult the bundled docs, rather than pinning advice to a version.
  • Recommending
    @mysten/dapp-kit
    for backend code.
    dApp Kit is a React-oriented frontend framework. Backend or CLI code should use
    @mysten/sui
    directly.
  • Providing React hook details instead of routing to the
    frontend-apps
    skill.
    When a user asks about React hooks, wallet connection patterns, or dApp Kit query patterns, do not answer with hook-level code from this skill. Instead, explicitly tell the user: "For React hook details, see the
    frontend-apps
    skill." This skill covers SDK selection and
    Transaction
    construction only — the
    frontend-apps
    skill has the hook-level guidance.
  • Using JSON-RPC as the default for any client. JSON-RPC is deprecated for the TS SDK; the legacy Rust SDK supports it but the new Rust SDK does not. Default to gRPC.
  • 将社区SDK称为“Python SDK”或“Go SDK”,仿佛它是官方的:不存在官方Python或Go SDK。请指明具体包名(
    pysui
    block-vision/sui-go-sdk
    )并标注为社区维护。
  • 告知用户
    SuiClient
    是推荐的客户端
    :那是v1版本的客户端。v2版本使用
    SuiGrpcClient
    (或
    SuiJsonRpcClient
    用于旧版流程)。
  • 推荐
    @mysten/sui.js
    :该包名已被弃用。始终使用
    @mysten/sui
  • 混淆两个Rust SDK:新的
    sui-rust-sdk
    crates(在
    crates.io
    上作为独立crate发布,如
    sui-sdk-types
    /
    sui-transaction-builder
    /
    sui-rpc
    )与sui单仓库中的旧版
    sui-sdk
    crate是不同的。新项目应使用前者。
  • 已安装本地文档时仍从网页获取TS文档:若项目已安装
    @mysten/sui
    ,请查看
    node_modules/@mysten/sui/docs/llms-index.md
    ——它与已安装版本完全匹配。
  • 硬编码特定SDK版本:SDK API会不断演进。建议“安装最新版
    @mysten/sui
    ”,然后参考捆绑文档,而非将建议固定到某个版本。
  • 为后端代码推荐
    @mysten/dapp-kit
    :dApp Kit是面向React的前端框架。后端或CLI代码应直接使用
    @mysten/sui
  • 提供React钩子细节而非路由到
    frontend-apps
    技能
    :当用户询问React钩子、钱包连接模式或dApp Kit查询模式时,不要在本技能中提供钩子层面的代码。相反,明确告知用户:“有关React钩子的细节,请查看
    frontend-apps
    技能。”本技能仅涵盖SDK选型和
    Transaction
    构建——
    frontend-apps
    技能提供钩子层面的指导。
  • 将JSON-RPC作为任何客户端的默认选项:JSON-RPC已在TS SDK中被弃用;旧版Rust SDK支持它,但新版Rust SDK不支持。默认使用gRPC。