sui-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sui Networks and Gas

Sui网络与Gas

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.
Source constraint: All information in this skill is sourced exclusively from docs.sui.io. When extending or updating this skill, only pull from this source. Do not use third-party blogs, tutorials, or unofficial documentation.

MCP工具: 当你的环境中可用时,也可查询Sui文档MCP服务器(
https://sui.mcp.kapa.ai
)获取最新答案。用它来验证信息,以及获取这些参考文件未涵盖的细节。
来源限制: 本技能中的所有信息均独家来自docs.sui.io。扩展或更新本技能时,仅可从此来源获取内容。请勿使用第三方博客、教程或非官方文档。

Related skills

相关技能

TopicSkill
CLI client configuration, addresses, faucets, explorers
sui-client/
Installing the Sui CLI (suiup)
sui-install/
Move project setup and Move.toml
sui-move-project/
Publishing and upgrading packages
sui-publish/

主题技能
CLI客户端配置、地址、水龙头及浏览器
sui-client/
安装Sui CLI(suiup)
sui-install/
Move项目设置与Move.toml
sui-move-project/
发布与升级包
sui-publish/

Sui networks

Sui网络

Sui operates four network environments:
  • Mainnet: Production network. SUI tokens have real monetary value. Use for final deployments.
  • Testnet: Mirrors Mainnet features. Free SUI tokens from faucets. Use for integration testing and staging.
  • Devnet: Development network. Free SUI tokens. Use for early-stage development and experimentation.
  • Localnet: Runs locally on your machine. Use for offline development and unit testing.
Sui运行四种网络环境:
  • Mainnet(主网): 生产网络。SUI代币具有真实货币价值。用于最终部署。
  • Testnet(测试网): 镜像主网功能。可从水龙头获取免费SUI代币。用于集成测试和预发布环境。
  • Devnet(开发网): 开发网络。提供免费SUI代币。用于早期开发和实验。
  • Localnet(本地网): 在你的本地机器上运行。用于离线开发和单元测试。

Gas cost model

Gas费用模型

Every transaction on Sui requires SUI tokens to pay gas. The total gas cost is:
gas cost = computation cost + storage cost - storage rebate
  • Computation cost: Proportional to the computational effort of executing the transaction.
  • Storage cost: The cost of storing new or expanded objects onchain. You pay for the bytes your objects occupy.
  • Storage rebate: When a transaction deletes objects or reduces their size, you receive a rebate for the storage freed. This incentivizes cleaning up unused state.
The gas budget (
--gas-budget
) sets the maximum you are willing to pay. If the transaction exceeds the budget, it aborts. On Testnet and Devnet, tokens are free through faucets (see the
sui-client
skill for faucet methods). Gas prices can vary per epoch; query the current gas price through the RPC.
Sui上的每笔交易都需要SUI代币来支付Gas。总Gas费用计算公式为:
Gas费用 = 计算成本 + 存储成本 - 存储返还
  • 计算成本: 与执行交易所需的计算工作量成正比。
  • 存储成本: 将新对象或扩容后的对象存储在链上的成本。你需要为对象占用的字节数付费。
  • 存储返还: 当交易删除对象或减小对象大小时,你会因释放的存储空间获得返还。这旨在激励清理未使用的状态。
Gas预算(
--gas-budget
)设置你愿意支付的最高费用。如果交易超出预算,将中止。在Testnet和Devnet上,可通过水龙头获取免费代币(获取方法请查看
sui-client
技能)。Gas价格可能随纪元变化;可通过RPC查询当前Gas价格。

Epochs

纪元(Epochs)

An epoch is a fixed time period during which the validator set and gas price remain constant. On Mainnet, one epoch is approximately 24 hours. At the epoch boundary, the network processes staking rewards, rotates validators, and updates the gas price. Use
ctx.epoch()
to read the current epoch number in Move and
ctx.epoch_timestamp_ms()
for the epoch start time.
纪元是一个固定时间段,在此期间验证者集合和Gas价格保持不变。在主网上,一个纪元约为24小时。在纪元边界,网络会处理质押奖励、轮换验证者并更新Gas价格。在Move中,可使用
ctx.epoch()
读取当前纪元编号,使用
ctx.epoch_timestamp_ms()
获取纪元开始时间。

Rules

规则

  • Always specify
    --gas-budget
    when submitting transactions from the CLI.
  • Use
    sui client switch --env <ENV>
    to change networks. Do not edit
    client.yaml
    manually.
  • 从CLI提交交易时,始终指定
    --gas-budget
  • 使用
    sui client switch --env <ENV>
    切换网络。请勿手动编辑
    client.yaml

Common mistakes

常见错误

  • Forgetting to switch networks. Publishing to Mainnet when you meant Testnet. Always verify with
    sui client active-env
    .
  • Running out of gas on Testnet/Devnet. Use the faucet (see
    sui-client
    skill) to get free tokens.
  • 忘记切换网络: 本想发布到Testnet却发布到了Mainnet。请始终使用
    sui client active-env
    验证当前网络。
  • 在Testnet/Devnet上Gas耗尽: 使用水龙头获取免费代币(请查看
    sui-client
    技能)。