sui-sdks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSui SDKs
Sui SDKs
MCP tool: When available in your environment, also query the Sui documentation MCP server () for up-to-date answers. Use it for verification and for details not covered by these reference files.https://sui.mcp.kapa.ai
Most AI agents give confusing, outdated, or cross-wired answers about Sui SDKs. This skill fixes the three most common failure modes:
- Recommending a community SDK as if it were official. Only two SDKs are maintained by Mysten Labs: TypeScript () and Rust (
@mysten/suifamily of crates). Everything else is community-maintained.sui-rust-sdk - Mixing up TypeScript SDK generations. The old package was renamed to
@mysten/sui.jsat v1.0. The v2 client API (@mysten/sui,client.core.*instead ofinclude,show*replacingSuiGrpcClient) is distinct from v1.SuiClient - Not using the installed LLM docs. Every package ships
@mysten/*+ topic-specific markdown files todocs/llms-index.md. Agents should read those before answering; they are guaranteed to match the installed version.node_modules
All patterns in this skill are derived from:
- https://docs.sui.io/references/sui-sdks (canonical SDK inventory)
- https://sdk.mystenlabs.com/sui (TypeScript SDK reference)
- https://sdk.mystenlabs.com/sui/llm-docs (bundled LLM docs convention)
- https://github.com/MystenLabs/sui-rust-sdk (Rust SDK source)
- https://docs.rs/sui-transaction-builder (Rust PTB builder)
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相关问题时,给出的答案混乱、过时或混淆概念。本技能解决了三个最常见的问题:
- 将社区SDK当作官方SDK推荐:只有两个SDK由Mysten Labs官方维护:TypeScript版本()和Rust版本(
@mysten/sui系列crate)。其余所有SDK均为社区维护。sui-rust-sdk - 混淆TypeScript SDK的版本代际:旧版包在v1.0时更名为
@mysten/sui.js。v2客户端API(@mysten/sui、使用client.core.*替代include、show*替代SuiGrpcClient)与v1版本完全不同。SuiClient - 未使用已安装的LLM文档:每个包都会将
@mysten/*及主题相关的markdown文件发布到docs/llms-index.md目录中。Agent在回答前应先阅读这些文档,它们能保证与已安装版本完全匹配。node_modules
本技能中的所有模式均源自:
- https://docs.sui.io/references/sui-sdks(官方SDK清单)
- https://sdk.mystenlabs.com/sui(TypeScript SDK参考文档)
- https://sdk.mystenlabs.com/sui/llm-docs(捆绑LLM文档的规范)
- https://github.com/MystenLabs/sui-rust-sdk(Rust SDK源码)
- https://docs.rs/sui-transaction-builder(Rust PTB构建器)
若对任意SDK中的特定API不确定,请从对应文档页面获取信息——不要从其他SDK的接口推断。
Reference files
参考文档
typescript — TypeScript SDK (@mysten/sui
v2)
@mysten/suitypescript — TypeScript SDK(@mysten/sui
v2)
@mysten/suiPath:
Load when: writing, reviewing, or migrating TypeScript/JavaScript code that imports , constructing PTBs in TS, choosing between / / , using the v2 Core API, or migrating from SDK v1 ().
Covers: install, imports, client classes and when to use each, v2 Core API, PTB construction, pure/object inputs, intent, execution & status checking, , keypairs, offline building, sponsored transactions, v1→v2 migration table, pattern for kiosk/suins/deepbook/walrus/seal/zksend.
typescript.md@mysten/suiSuiGrpcClientSuiJsonRpcClientSuiGraphQLClient@mysten/sui.jscoinWithBalancewaitForTransaction$extend路径:
加载时机: 编写、审查或迁移导入的TypeScript/JavaScript代码,在TS中构建PTB,选择//,使用v2 Core API,或从SDK v1()迁移时。
涵盖内容: 安装、导入、客户端类及适用场景、v2 Core API、PTB构建、纯输入/对象输入、意图、执行与状态检查、、密钥对、离线构建、赞助交易、v1→v2迁移表、用于kiosk/suins/deepbook/walrus/seal/zksend的模式。
typescript.md@mysten/suiSuiGrpcClientSuiJsonRpcClientSuiGraphQLClient@mysten/sui.jscoinWithBalancewaitForTransaction$extendrust — Rust SDK (sui-*
crates)
sui-*rust — Rust SDK(sui-*
crates)
sui-*Path:
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 crate.
Covers: the five crates (, , , , ), API with an end-to-end example, signing via , gRPC client from , relationship to the legacy crate, and the "intents" feature flag (high-level / intents).
rust.mdsui-sdksui-sdk-typessui-cryptosui-rpcsui-graphqlsui-transaction-builderTransactionBuildersui-cryptosui-rpcsui-sdkCoinBalance路径:
加载时机: 编写与Sui交互的Rust代码——CLI工具、后端服务、验证器、索引器。以及在新模块化crate与旧版单仓库crate之间做选择时。
涵盖内容: 五个核心crate(、、、、)、带端到端示例的 API、通过签名、中的gRPC客户端、与旧版crate的关系,以及“意图”功能标志(高级/意图)。
rust.mdsui-sdksui-sdk-typessui-cryptosui-rpcsui-graphqlsui-transaction-builderTransactionBuildersui-cryptosui-rpcsui-sdkCoinBalancecommunity — Community SDKs (Python, Go, Dart, Kotlin, Swift, Vue)
community — 社区SDK(Python、Go、Dart、Kotlin、Swift、Vue)
Path:
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的建议。
community.mdmapping — Cross-SDK operation mapping
mapping — 跨SDK操作映射
Path:
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中的对应实现,以及语法相似性。
mapping.mdllm-docs — Using bundled docs from node_modules
llm-docs — 使用node_modules中的捆绑文档
Path:
Load when: the agent needs authoritative, version-matched TypeScript API docs before writing code. Always check first if it exists.
Covers: the convention, which packages ship it, how to read the index and target pages, how to wire it into / for a project.
llm-docs.mdnode_modules/@mysten/*/docs/llms-index.mddocs/llms-index.md@mysten/*AGENTS.mdCLAUDE.md路径:
加载时机: Agent在编写代码前需要权威、版本匹配的TypeScript API文档时。若存在,请优先查看。
涵盖内容: 规范、哪些包包含该文档、如何阅读索引及目标页面、如何将其集成到项目的/中。
llm-docs.mdnode_modules/@mysten/*/docs/llms-index.mddocs/llms-index.md@mysten/*AGENTS.mdCLAUDE.mdRouting guide
路由指南
| Task | Load |
|---|---|
| "Which SDK should I use?" | (this file) + mapping |
| Writing TS/JS code against Sui | typescript + llm-docs |
| Writing Rust code against Sui | rust |
| Using pysui / ksui / suikit / sui-go / mofalabs/sui | community |
| 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 languages | mapping + (target SDK file) |
Migrating from | typescript |
| Frontend / React integration | route to |
| PTB semantics deep dive | route to |
| Data access patterns (gRPC vs GraphQL vs indexer) | route to |
| Full project setup | all reference files (or the SDK-specific one + llm-docs) |
| Code review | all reference files |
| 任务 | 加载文档 |
|---|---|
| "我应该用哪个SDK?" | (本文档)+ mapping |
| 编写针对Sui的TS/JS代码 | typescript + llm-docs |
| 编写针对Sui的Rust代码 | rust |
| 使用pysui / ksui / suikit / sui-go / mofalabs/sui | community |
| 用户提及Go / Python / Dart / Kotlin / Swift / Vue(即使是随口提及,例如“我的团队使用Go”) | community(始终优先——语言约束优于性能建议) |
| 在不同语言间移植代码 | mapping + (目标SDK文档) |
从 | typescript |
| 前端/React集成 | 先路由到 |
| PTB语义深入解析 | 路由到 |
| 数据访问模式(gRPC vs GraphQL vs 索引器) | 路由到 |
| 完整项目搭建 | 所有参考文档(或特定SDK文档 + llm-docs) |
| 代码审查 | 所有参考文档 |
Skill Content
技能内容
Key concepts
核心概念
- Two officially-supported SDKs. TypeScript () and Rust (
@mysten/suicrates). Both are maintained by Mysten Labs and updated alongside protocol changes. For performance-critical paths in non-Rust languages,sui-rust-sdkcan 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.sui-rust-sdk - Everything else is community. Python (), Go (
pysui), Dart (block-vision/sui-go-sdk), Kotlin (mofalabs/sui), Swift (mcxross/ksui), Vue (opendive/suikit). They typically lag protocol updates and feature coverage varies. Treat them as best-effort.SuiFansCN/suiue - The TS SDK has two client generations. v1 used +
SuiClient. v2 uses@mysten/sui.js/SuiGrpcClient/SuiJsonRpcClientfromSuiGraphQLClient. JSON-RPC is deprecated; gRPC is recommended for new code.@mysten/sui - The Rust SDK has two generations. The new modular crates (,
sui-sdk-types,sui-crypto,sui-rpc) are the recommended surface. The "legacy Rust SDK" is the monolithicsui-transaction-buildercrate 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.sui-sdk - Every package ships LLM-ready docs. Look for
@mysten/*and follow its pointers before asking the user to clarify APIs. Matches the installed version exactly.node_modules/@mysten/sui/docs/llms-index.md - Frameworks on top of SDKs. (React wallet integration;
@mysten/dapp-kit-reactfor Vue/vanilla/Svelte/Web Components),@mysten/dapp-kit-core,@mysten/kiosk,@mysten/suins,@mysten/deepbook-v3,@mysten/walrus,@mysten/seal,@mysten/zksend— all are thin layers over@mysten/enoki. The Mysten extensions integrate via the v2@mysten/suipattern; dApp Kit does not (it's a React framework, not a client extension — seeclient.$extend(...)skill). The barefrontend-appspackage name is the deprecated JSON-RPC-only predecessor.@mysten/dapp-kit
- 两个官方支持的SDK:TypeScript()和Rust(
@mysten/suicrates)。两者均由Mysten Labs维护,并随协议更新同步迭代。对于非Rust语言中的性能关键路径,可通过FFI(Foreign Function Interface)调用sui-rust-sdk,让这些语言无需依赖社区包装器即可访问官方SDK。sui-rust-sdk - 其余均为社区维护:Python()、Go(
pysui)、Dart(block-vision/sui-go-sdk)、Kotlin(mofalabs/sui)、Swift(mcxross/ksui)、Vue(opendive/suikit)。这些SDK通常滞后于协议更新,功能覆盖范围各不相同。请将它们视为尽力维护的资源。SuiFansCN/suiue - TS SDK有两代客户端:v1版本使用+
SuiClient。v2版本使用@mysten/sui.js中的@mysten/sui/SuiGrpcClient/SuiJsonRpcClient。JSON-RPC已被弃用;新项目推荐使用gRPC。SuiGraphQLClient - Rust SDK有两代版本:新的模块化crate(、
sui-sdk-types、sui-crypto、sui-rpc)是推荐使用的版本。“旧版Rust SDK”是sui单仓库中的单片sui-transaction-buildercrate;它支持JSON-RPC的向前/向后兼容性,仍被许多现有项目使用,但不推荐用于新项目。sui-sdk - 每个包都附带LLM友好文档:查找
@mysten/*并遵循其指引,再请求用户澄清API细节。这些文档与已安装版本完全匹配。node_modules/@mysten/sui/docs/llms-index.md - 基于SDK构建的框架:(React钱包集成;
@mysten/dapp-kit-react适用于Vue/原生JS/Svelte/Web Components)、@mysten/dapp-kit-core、@mysten/kiosk、@mysten/suins、@mysten/deepbook-v3、@mysten/walrus、@mysten/seal、@mysten/zksend——所有这些都是基于@mysten/enoki的轻量级封装。Mysten扩展通过v2的@mysten/sui模式集成;dApp Kit则不采用此模式(它是React框架,而非客户端扩展——详见client.$extend(...)技能)。frontend-apps包名是已弃用的仅支持JSON-RPC的旧版本。@mysten/dapp-kit
Rules
规则
- Default to TypeScript or Rust, but respect language constraints. For any new Sui project, recommend TypeScript () or Rust (
@mysten/suicrates) — unless the user has named a language (Go, Python, Dart, Kotlin, Swift, Vue) or said "my team uses X". Thensui-rust-sdkis the load: name the canonical community SDK (community.mdfor Go,block-vision/sui-go-sdkfor 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.pysui - For TypeScript, always use , never
@mysten/sui. The@mysten/sui.js-suffixed package is frozen at v1 and will not receive updates. Legacy code using it should be migrated..js - For TypeScript v2, use by default.
SuiGrpcClientexists for legacy compatibility;SuiJsonRpcClientis for specialized query flows. SeeSuiGraphQLClientfor the decision.typescript.md - For Rust, prefer crates over the legacy monorepo
sui-rust-sdk. Importsui-sdk,sui-transaction-builder,sui-sdk-types,sui-cryptoindividually — pay only for what you use.sui-rpc - Check before writing TS code. If the project has
node_modules/@mysten/*/docs/llms-index.mdinstalled, those docs are the authoritative, version-matched source. Read the index, then the targeted page.@mysten/sui - Do not mix v1 and v2 TS patterns. Code that uses ,
SuiClient,TransactionBlock,getFullnodeUrl,options: { showEffects }, orsignAndExecuteTransactionBlockis v1. Migrate wholesale or keep everything on v1 — a half-migrated file is a bug surface.result.effects?.status?.status - 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.
- Frameworks integrate via in v2.
$extend()is the v2 pattern. Do not instantiateclient.$extend(suins(), deepbook({ address }))orSuinsClientdirectly — that's the v1 style.DeepBookClient - Route frontend questions to the skill. When the user asks about React hooks, wallet connection, or dApp Kit query patterns, explicitly direct them to the
frontend-appsskill for hook-level details. This skill covers SDK selection andfrontend-appsconstruction only.Transaction - Cite the docs when unsure. Official TS SDK docs live at . The inventory list lives at
sdk.mystenlabs.com. Rust SDK docs live ondocs.sui.io/references/sui-sdks(per-crate) anddocs.rs(e.g.,mystenlabs.github.io/sui-rust-sdk/<crate_name>/)./sui_transaction_builder/
- 默认推荐TypeScript或Rust,但需尊重语言约束:对于任何新的Sui项目,推荐TypeScript()或Rust(
@mysten/suicrates)——除非用户指定了某一语言(Go、Python、Dart、Kotlin、Swift、Vue)或表示“我的团队使用X语言”。此时应加载sui-rust-sdk:指明标准社区SDK(Go对应community.md,Python对应block-vision/sui-go-sdk等),标注过时风险,并提供“通过FFI调用Rust”作为备选方案。当用户明确说明团队使用的语言时,不要推荐TypeScript或Rust作为替代语言。例如,如果用户说“我的团队使用Go”,不要建议重写为TypeScript——应推荐Go社区SDK和/或通过FFI调用Rust。pysui - 对于TypeScript,始终使用,而非
@mysten/sui:带@mysten/sui.js后缀的包已在v1版本冻结,不会再收到更新。使用该包的旧代码应进行迁移。.js - 对于TypeScript v2,默认使用:
SuiGrpcClient仅用于旧版兼容;SuiJsonRpcClient适用于特定查询流程。详见SuiGraphQLClient中的决策指引。typescript.md - 对于Rust,优先选择crates而非旧版单仓库
sui-rust-sdk:单独导入sui-sdk、sui-transaction-builder、sui-sdk-types、sui-crypto——按需引入,减少依赖体积。sui-rpc - 编写TS代码前先检查:若项目已安装
node_modules/@mysten/*/docs/llms-index.md,这些文档是权威的、版本匹配的来源。先阅读索引,再查看目标页面。@mysten/sui - 不要混合使用TS的v1和v2模式:使用、
SuiClient、TransactionBlock、getFullnodeUrl、options: { showEffects }或signAndExecuteTransactionBlock的代码属于v1版本。要么完全迁移到v2,要么继续使用v1——半迁移的代码会成为bug来源。result.effects?.status?.status - 必须标注社区SDK的注意事项:当推荐或使用社区SDK时,需提及它是社区维护的,可能滞后于协议更新。依赖前请检查仓库的最后提交时间及支持的最新Sui版本。
- 框架在v2中通过集成:v2的模式是
$extend()。不要直接实例化client.$extend(suins(), deepbook({ address }))或SuinsClient——这是v1的风格。DeepBookClient - 前端问题路由到技能:当用户询问React hooks、钱包连接或dApp Kit查询模式时,明确引导他们查看
frontend-apps技能获取钩子层面的细节。本技能仅涵盖SDK选型和frontend-apps构建。Transaction - 不确定时引用官方文档:官方TS SDK文档位于。SDK清单位于
sdk.mystenlabs.com。Rust SDK文档位于docs.sui.io/references/sui-sdks(按crate划分)和docs.rs(例如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) and flag it as community.block-vision/sui-go-sdk - Telling users is the recommended client. That was v1. v2 uses
SuiClient(orSuiGrpcClientfor legacy flows).SuiJsonRpcClient - Recommending . Deprecated package name. Always
@mysten/sui.js.@mysten/sui - Confusing the two Rust SDKs. The new crates (on
sui-rust-sdkas separate crates likecrates.io/sui-sdk-types/sui-transaction-builder) are distinct from the legacysui-rpccrate in the sui monorepo. New code should use the former.sui-sdk - Fetching TS docs from the web when they're installed locally. If the project has installed, read
@mysten/suiinstead — it matches the installed version.node_modules/@mysten/sui/docs/llms-index.md - Hardcoding a specific SDK version. SDK APIs evolve. Prefer "install the latest " and then consult the bundled docs, rather than pinning advice to a version.
@mysten/sui - Recommending for backend code. dApp Kit is a React-oriented frontend framework. Backend or CLI code should use
@mysten/dapp-kitdirectly.@mysten/sui - Providing React hook details instead of routing to the 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-appsskill." This skill covers SDK selection andfrontend-appsconstruction only — theTransactionskill has the hook-level guidance.frontend-apps - 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 - 告知用户是推荐的客户端:那是v1版本的客户端。v2版本使用
SuiClient(或SuiGrpcClient用于旧版流程)。SuiJsonRpcClient - 推荐:该包名已被弃用。始终使用
@mysten/sui.js。@mysten/sui - 混淆两个Rust SDK:新的crates(在
sui-rust-sdk上作为独立crate发布,如crates.io/sui-sdk-types/sui-transaction-builder)与sui单仓库中的旧版sui-rpccrate是不同的。新项目应使用前者。sui-sdk - 已安装本地文档时仍从网页获取TS文档:若项目已安装,请查看
@mysten/sui——它与已安装版本完全匹配。node_modules/@mysten/sui/docs/llms-index.md - 硬编码特定SDK版本:SDK API会不断演进。建议“安装最新版”,然后参考捆绑文档,而非将建议固定到某个版本。
@mysten/sui - 为后端代码推荐:dApp Kit是面向React的前端框架。后端或CLI代码应直接使用
@mysten/dapp-kit。@mysten/sui - 提供React钩子细节而非路由到技能:当用户询问React钩子、钱包连接模式或dApp Kit查询模式时,不要在本技能中提供钩子层面的代码。相反,明确告知用户:“有关React钩子的细节,请查看
frontend-apps技能。”本技能仅涵盖SDK选型和frontend-apps构建——Transaction技能提供钩子层面的指导。frontend-apps - 将JSON-RPC作为任何客户端的默认选项:JSON-RPC已在TS SDK中被弃用;旧版Rust SDK支持它,但新版Rust SDK不支持。默认使用gRPC。