Loading...
Loading...
Compare original and translation side by side
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
Source constraint: All information sourced exclusively from docs.sui.io and MystenLabs/sui-stack-hello-world.
MCP工具: 如果您的环境中可用,也可查询Sui文档MCP服务器()获取最新答案。用它来验证信息以及获取这些参考文件未涵盖的细节。https://sui.mcp.kapa.ai
来源限制: 所有信息均独家来自docs.sui.io和MystenLabs/sui-stack-hello-world。
cd sui-stack-hello-world/move/hello-world
sui move build
sui client publishsui-stack-hello-world/ui/src/constants.tsTESTNET_HELLO_WORLD_PACKAGE_IDcd sui-stack-hello-world/move/hello-world
sui move build
sui client publishsui-stack-hello-world/ui/src/constants.tsTESTNET_HELLO_WORLD_PACKAGE_IDsui client active-envsui client balancesui move buildsui client active-envsui client balancesui move buildsui client publishinitsui client publishinitsui client test-publishsui client test-publishinitsui client publishinittest-publish--build-envsui client test-publish --build-env testnetsui client test-publishsui client test-publishinitsui client publishinittest-publish--build-envsui client test-publish --build-env testnetUpgradeCapinitpublished-atPublished.tomlundefinedUpgradeCapinitpublished-atPublished.tomlundefinedundefinedundefinedsui client publishPublished.tomlsui client switch --env <ENV>sui client publishPublished.tomlPublished.tomlsui client upgradesui client publishPublished.tomlsui client switch --env <ENV>sui client publishPublished.tomlPublished.tomlsui client upgradeUpgradeCapUpgradeCappublishsui::package::only_additive_upgradessui client upgrade --upgrade-capability <CAP_ID>UpgradeCappublishUpgradeCapsui::package::only_additive_upgradessui client upgrade --upgrade-capability <CAP_ID>UpgradeCapPublished.tomlupgrade-capabilityUpgradeCapsui client objects --type 0x2::package::UpgradeCapsui client publishUpgradeCapsuivision.xyzsuiscan.xyz0x2::package::UpgradeCapUpgradeCapPublished.tomlupgrade-capabilityUpgradeCapsui client objects --type 0x2::package::UpgradeCapsui client publishUpgradeCapsuivision.xyzsuiscan.xyz0x2::package::UpgradeCapUpgradeCappublishsui::package::only_additive_upgradesUpgradeCapsui::package::make_immutableUpgradeCapUpgradeCapUpgradeCapsui::package::only_additive_upgradessui::package::make_immutableUpgradeCapkeystorecopydropsui client upgradekeystorecopydropsui client upgradelistOwnedObjectstypemoveCallORIGINAL_PACKAGE_IDPACKAGE_ID// Original publish → package ID 0x1234...
// After upgrade → package ID 0x5678...
// Query: use ORIGINAL package ID
client.core.listOwnedObjects({
owner: addr,
type: '0x1234...::module::MyObject', // ✅ original ID
});
// Call: use UPGRADED package ID
tx.moveCall({
target: '0x5678...::module::my_function', // ✅ upgraded ID
});typelistOwnedObjectsmoveCallORIGINAL_PACKAGE_IDPACKAGE_ID// 首次发布 → 包ID 0x1234...
// 升级后 → 包ID 0x5678...
// 查询:使用原始包ID
client.core.listOwnedObjects({
owner: addr,
type: '0x1234...::module::MyObject', // ✅ 原始ID
});
// 调用:使用升级后的包ID
tx.moveCall({
target: '0x5678...::module::my_function', // ✅ 升级后的ID
});Published.tomlfaucet.sui.io!faucet <ADDRESS>#testnet-faucetrequestSuiFromFaucetV2()sui client faucetsui client faucetfaucet.sui.io!faucet <ADDRESS>#devnet-faucetsui client faucet127.0.0.1:5003/gas127.0.0.1:9123/gassui start --with-faucet --force-regenesisPublished.tomlfaucet.sui.io#testnet-faucet!faucet <ADDRESS>requestSuiFromFaucetV2()sui client faucetsui client faucetfaucet.sui.io#devnet-faucet!faucet <ADDRESS>sui client faucet127.0.0.1:5003/gas127.0.0.1:9123/gassui start --with-faucet --force-regenesissui client publish --serialize-outputsui client publish --serialize-outputsui start --with-faucet --force-regenesis--force-regenesis--with-faucetsui client switch --env localnetsui client faucet127.0.0.1:5003/gas127.0.0.1:9123/gasinitsui start --with-faucet --force-regenesis--force-regenesis--with-faucetsui client switch --env localnetsui client faucet127.0.0.1:5003/gas127.0.0.1:9123/gasinitsui move testsui move test --coverage
sui move coverage summarysui move testsui move test --coverage
sui move coverage summaryMove.tomledition = "2024"[addresses][environments]mainnet{ r.mvr = "@org/package" }sui move buildMove.tomledition = "2024"[addresses][environments]mainnet{ r.mvr = "@org/package" }sui move build| Policy | What you can change | When to use |
|---|---|---|
| Compatible (default) | Add functions, add modules, update implementations. Cannot remove functions or change struct layouts. | Most packages — gives flexibility for bug fixes while preserving type safety. |
| Additive | Add new modules only. Existing modules are frozen. | Packages where you want to extend functionality but guarantee existing code never changes. |
| Dependency-only | Only update dependency versions. | Nearly-finalized packages that should only track framework updates. |
| Immutable | Nothing. Package is permanently frozen. | Fully audited packages where immutability is a trust guarantee (e.g., token contracts). |
moveCallsui::package::only_additive_upgradesonly_dep_upgradesmake_immutableUpgradeCap| 策略 | 可修改内容 | 使用场景 |
|---|---|---|
| 兼容策略(默认) | 添加函数、添加模块、更新实现。无法删除函数或修改结构体布局。 | 大多数包——在保留类型安全的同时,为bug修复提供灵活性。 |
| 增量策略 | 仅能添加新模块。现有模块被冻结。 | 需要扩展功能但保证现有代码永不修改的包。 |
| 仅依赖更新策略 | 仅能更新依赖版本。 | 接近最终版本、仅需跟踪框架更新的包。 |
| 不可变策略 | 无任何修改。包永久冻结。 | 经过全面审计、不可变性是信任保障的包(例如代币合约)。 |
UpgradeCapsui::package::only_additive_upgradesonly_dep_upgradesmake_immutablemoveCallsui client publish --dry-runcomputationCoststorageCoststorageRebatecomputationCost + storageCost - storageRebatesui client publish --dry-runcomputationCoststorageCoststorageRebatecomputationCost + storageCost - storageRebateUpgradeCapUpgradeCap--serialize-outputUpgradeCapUpgradeCapsui::package::make_immutableundefinedUpgradeCapUpgradeCap--serialize-outputUpgradeCapUpgradeCapsui::package::make_immutableundefinedundefinedundefinedsui client active-envmainnetsui client balancesui move buildsui move testMove.tomleditionsui client active-envmainnetsui client balancesui move buildsui move testMove.tomleditiondevInspectTransactionBlock--dry-runsui client active-envdevInspectTransactionBlock--dry-runsui client active-env| Signal | How | Why |
|---|---|---|
| Failed transactions involving your package | Subscribe to transaction effects via gRPC streaming, filter by package ID | Detects Move aborts, gas failures, or unexpected reverts in production |
| Gas spend | Track | Catch unexpectedly expensive operations or gas drain attacks |
| Event emission | Subscribe to events by type ( | Core business telemetry — mints, transfers, admin actions, deny list changes |
| Object creation/deletion rates | Query or subscribe to object changes filtered by your types | Detect abnormal activity (mass minting, object spam) |
| Admin/cap usage | Filter events for capability-gated actions | Detect unauthorized or unexpected admin operations |
| Shared object contention | Monitor transaction latency for shared-object transactions | High contention degrades UX; may need object sharding |
| 指标 | 实现方式 | 原因 |
|---|---|---|
| 涉及您包的失败交易 | 通过gRPC流订阅交易效果,按包ID过滤 | 检测生产环境中的Move中止、gas失败或意外回滚 |
| Gas消耗 | 跟踪交易效果中的 | 发现异常昂贵的操作或gas耗尽攻击 |
| 事件发射 | 通过gRPC流按类型( | 核心业务遥测——铸造、转账、管理员操作、黑名单变更 |
| 对象创建/删除速率 | 查询或订阅按您的类型过滤的对象变更 | 检测异常活动(大规模铸造、对象垃圾信息) |
| 管理员/权限使用 | 过滤权限 gated 操作的事件 | 检测未授权或意外的管理员操作 |
| 共享对象竞争 | 监控共享对象交易的延迟 | 高竞争会降低用户体验;可能需要对象分片 |
for await (const event of client.subscriptionService.subscribeEvents({
filter: { MoveEventModule: { package: PACKAGE_ID, module: 'my_module' } },
})) {
// Forward to your monitoring stack (Grafana, Datadog, PagerDuty, etc.)
}sui-indexer-altaccessing-dataindexers.mdfor await (const event of client.subscriptionService.subscribeEvents({
filter: { MoveEventModule: { package: PACKAGE_ID, module: 'my_module' } },
})) {
// 转发到您的监控栈(Grafana、Datadog、PagerDuty等)
}sui-indexer-altaccessing-dataindexers.mdrevertrollbackrevertrollbacksui client upgradePACKAGE_IDSORIGINAL_PACKAGE_IDSsui client upgradePACKAGE_IDSORIGINAL_PACKAGE_IDSUpgradeCaponly_dep_upgradesmake_immutableUpgradeCapUpgradeCaponly_dep_upgradesmake_immutableUpgradeCapAdminCapAdminCapUpgradeCapadditivedep_onlyUpgradeCapadditivedep_only