hiero-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesehiero-cli (hcli)
hiero-cli (hcli)
hclihcliBinary syntax
命令语法
hcli <plugin> <command> [options]hcli <plugin> <command> [options]Global flags
全局标志
| Flag | Short | Default | Description |
|---|---|---|---|
| | | Output format: |
| | active | Override active network for this command |
| | operator | Override payer account for this command; defaults to operator if omitted |
| | | Skip all confirmation prompts |
| | config | Max transaction fee ceiling for this run: HBAR (e.g. |
| 标志 | 简写 | 默认值 | 描述 |
|---|---|---|---|
| | | 输出格式: |
| | active | 覆盖本次命令使用的活跃网络 |
| | operator | 覆盖本次命令的付款方账户;若省略则默认为operator |
| | | 跳过所有确认提示 |
| | config | 本次运行的最大交易费上限:单位为HBAR(例如 |
Prerequisites
前置条件
Before executing blockchain commands:
- Configure network:
hcli network use --global testnet - Set operator:
hcli network set-operator --operator <accountId>:<privateKey>
执行区块链命令之前:
- 配置网络:
hcli network use --global testnet - 设置operator:
hcli network set-operator --operator <accountId>:<privateKey>
Key formats
密钥格式
Keys and signers accept multiple formats:
- — inline pair, e.g.
{accountId}:{privateKey}0.0.123:abc123... - — raw private key with type prefix
{ed25519|ecdsa}:private:{hex} - — raw public key (for supply/submit keys)
{ed25519|ecdsa}:public:{hex} - — key reference stored in KMS
kr_xxx - account alias — name registered in local state
密钥和签名者支持多种格式:
- — 内联对,例如
{accountId}:{privateKey}0.0.123:abc123... - — 带类型前缀的原始私钥
{ed25519|ecdsa}:private:{hex} - — 原始公钥(用于供应/提交密钥)
{ed25519|ecdsa}:public:{hex} - — 存储在KMS中的密钥引用
kr_xxx - 账户别名 — 在本地状态中注册的名称
Local state storage
本地状态存储
State is persisted in as JSON files, one per plugin namespace:
~/.hiero-cli/state/| Plugin | File |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
状态以JSON文件形式持久化存储在 目录下,每个插件命名空间对应一个文件:
~/.hiero-cli/state/| 插件 | 文件 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Amount notation
金额表示法
- = 1 display unit (e.g. 1 HBAR, or 1 token with decimals applied)
"1" - = 100 base/raw units (tinybars for HBAR, smallest token unit)
"100t"
- = 1个显示单位(例如1 HBAR,或应用了小数位数的1个代币)
"1" - = 100个基础/原始单位(HBAR对应tinybars,即代币最小单位)
"100t"
Plugin catalog
插件目录
| Plugin | Description | Tasks covered |
|---|---|---|
| Manage Hedera accounts | create, import, balance, list, view, update, delete, clear |
| Transfer HBAR | transfer HBAR, approve/revoke HBAR allowance |
| Manage FT & NFT tokens | create-ft/nft, create-from-file, mint, burn, wipe, transfer, airdrop, associate, dissociate, freeze/unfreeze, pause/unpause, grant/revoke KYC, allowance (FT/NFT), delete-allowance-nft, update-metadata-nft, pending-airdrops, cancel/claim/reject-airdrop, list, view, import, delete |
| Hedera Consensus Service | create, update, submit/find messages, import, list, delete |
| Scheduled transactions | create schedule record, sign pending schedule, delete schedule, verify execution state, list schedules. Use |
| Smart contract lifecycle | compile + deploy Solidity, import, list, delete |
| ERC-20 contract calls | name, symbol, decimals, balanceOf, transfer, transferFrom, approve, allowance, totalSupply. Requires |
| ERC-721 contract calls | balanceOf, ownerOf, approve, setApprovalForAll, safeTransferFrom, transferFrom, mint, name, symbol, tokenURI, getApproved, isApprovedForAll. Requires |
| Network configuration | list networks, switch network, set/get operator |
| CLI configuration | list, get, set config options |
| Key/credentials management | generate new key, import existing key, list, remove stored credentials (by id or alias) |
| Batch transactions | create batch, add transactions, execute, list, delete |
| Multi-party asset exchange | create swap, add HBAR/FT/NFT transfers, view, list, execute, delete |
| EIP-712 typed data signing | |
| x402 payment signing | sign a |
| Plugin lifecycle | add, remove, enable, disable, list, reset, info |
| 插件 | 描述 | 涵盖任务 |
|---|---|---|
| 管理Hedera账户 | 创建、导入、查询余额、列表、查看、更新、删除、清除 |
| 转移HBAR | 转移HBAR、批准/撤销HBAR额度 |
| 管理FT和NFT代币 | 创建FT/NFT、从文件创建、铸造、销毁、擦除、转移、空投、关联、解除关联、冻结/解冻、暂停/恢复、授予/撤销KYC、额度(FT/NFT)、删除NFT额度、更新NFT元数据、待处理空投、取消/领取/拒绝空投、列表、查看、导入、删除 |
| Hedera共识服务 | 创建、更新、提交/查找消息、导入、列表、删除 |
| 计划交易 | 创建计划记录、签署待处理计划、删除计划、验证执行状态、列出计划。仅在插件参考中标记为 |
| 智能合约生命周期 | 编译并部署Solidity合约、导入、列表、删除 |
| ERC-20合约调用 | name、symbol、decimals、balanceOf、transfer、transferFrom、approve、allowance、totalSupply。需要 |
| ERC-721合约调用 | balanceOf、ownerOf、approve、setApprovalForAll、safeTransferFrom、transferFrom、mint、name、symbol、tokenURI、getApproved、isApprovedForAll。需要 |
| 网络配置 | 列出网络、切换网络、设置/获取operator |
| CLI配置 | 列出、获取、设置配置项 |
| 密钥/凭证管理 | 生成新密钥、导入现有密钥、列出、删除存储的凭证(按ID或别名) |
| 批量交易 | 创建批量、添加交易、执行、列表、删除 |
| 多方资产交换 | 创建交换、添加HBAR/FT/NFT转账、查看、列表、执行、删除 |
| EIP-712类型化数据签名 | |
| x402支付签名 | 通过KMS将 |
| 插件生命周期 | 添加、移除、启用、禁用、列表、重置、信息 |
Agent instruction
Agent指令
Before executing any command, read for the full command spec, all options, and examples.
references/<plugin>.mdExample: to use , first read .
hcli token create-ftreferences/token.mdWhen working with batch commands, read both AND the reference for the plugin being batched.
references/batch.mdExample: to batch , read both and .
hcli token mint-ftreferences/batch.mdreferences/token.mdWhen working with scheduled transactions, read AND the reference for the command being scheduled.
references/schedule.mdOnly commands marked [scheduled] in their reference support / .
--scheduled <name>-XExample: to schedule , read both and .
hcli token burn-ftreferences/schedule.mdreferences/token.md执行任何命令之前,请阅读 了解完整的命令规范、所有选项和示例。
references/<plugin>.md示例:要使用 ,请先阅读 。
hcli token create-ftreferences/token.md处理批量命令时,请同时阅读 和被批量处理的插件的参考文档。
references/batch.md示例:要批量执行 ,请同时阅读 和 。
hcli token mint-ftreferences/batch.mdreferences/token.md处理计划交易时,请阅读 和被计划的命令的参考文档。
references/schedule.md仅在参考文档中标记为 [scheduled] 的命令支持 / 参数。
--scheduled <name>-X示例:要计划执行 ,请同时阅读 和 。
hcli token burn-ftreferences/schedule.mdreferences/token.mdx402 paid endpoints
x402付费端点
If fetching a URL returns HTTP with a header, the
endpoint is x402-gated. Inspect the header payload: if its lists a
/ requirement, read
and follow the flow there. The agent makes the HTTP
requests itself; only produces the value.
If the challenge is for a non-Hedera scheme, this CLI cannot sign it.
402PAYMENT-REQUIREDacceptshedera:mainnethedera:testnetexactreferences/x402.mdhcli x402 signPAYMENT-SIGNATURE如果请求URL返回HTTP 状态码并带有 头,则该端点是x402门禁的。检查头payload:如果其 列表中包含 / 的 要求,请阅读 并遵循其中的流程。Agent会自行发起HTTP请求; 仅生成 值。如果挑战是针对非Hedera方案的,此CLI无法对其签名。
402PAYMENT-REQUIREDacceptshedera:mainnethedera:testnetexactreferences/x402.mdhcli x402 signPAYMENT-SIGNATUREhcli not found / not installed
未找到hcli / 未安装
If any command fails with a "command not found" or similar error, tell the user:
hcliis not installed or not available in PATH. Docs & quick start: https://www.npmjs.com/package/@hiero-ledger/hiero-cli#quick-starthcliInstall with:npm install -g @hiero-ledger/hiero-cliWould you like me to run the install command for you?
Do not run the install automatically — wait for the user's confirmation.
如果任何 命令失败并出现“command not found”或类似错误,请告知用户:
hcli未安装或不在PATH中。 文档与快速入门:https://www.npmjs.com/package/@hiero-ledger/hiero-cli#quick-starthcli安装命令:npm install -g @hiero-ledger/hiero-cli你是否需要我帮你运行安装命令?
请勿自动运行安装命令 — 请等待用户确认。
Operator not configured
Operator未配置
If a command fails with or similar:
CLI operator is not configured- Inform the user the operator must be set before running any blockchain command
- Guide them:
hcli network set-operator --operator <accountId>:<privateKey> - Retry the original command after operator is set
如果命令失败并出现 或类似错误:
CLI operator is not configured- 告知用户在运行任何区块链命令之前必须设置operator
- 指导他们执行:
hcli network set-operator --operator <accountId>:<privateKey> - 设置好operator后重试原始命令
Disabled plugin recovery
禁用插件恢复
If a command fails with :
Plugin 'X' is disabled.- Inform the user that the plugin is disabled
- Offer to enable it:
hcli plugin-management enable --name X - Retry the original command after enabling
如果命令失败并出现 错误:
Plugin 'X' is disabled.- 告知用户该插件已被禁用
- 提议启用它:
hcli plugin-management enable --name X - 启用后重试原始命令
Common workflows
常用工作流
Setup (first time)
首次设置
bash
hcli network use --global testnet
hcli network set-operator --operator 0.0.12345:302e...privatekey...bash
hcli network use --global testnet
hcli network set-operator --operator 0.0.12345:302e...privatekey...Create fungible token and transfer
创建同质化代币并转账
bash
undefinedbash
undefined1. Create token
1. Create token
hcli token create-ft --token-name "MyToken" --symbol MTK --decimals 2 --initial-supply 1000000
hcli token create-ft --token-name "MyToken" --symbol MTK --decimals 2 --initial-supply 1000000
2. Associate recipient account
2. Associate recipient account
hcli token associate --token MTK --account 0.0.67890:302e...key...
hcli token associate --token MTK --account 0.0.67890:302e...key...
3. Transfer tokens
3. Transfer tokens
hcli token transfer-ft --token MTK --to 0.0.67890 --amount 100
undefinedhcli token transfer-ft --token MTK --to 0.0.67890 --amount 100
undefinedDeploy ERC-20 contract and interact
部署ERC-20合约并交互
bash
undefinedbash
undefined1. Deploy built-in ERC-20 template
1. Deploy built-in ERC-20 template
hcli contract create --name myErc20 --default erc20 --constructor-parameter "MyToken" --constructor-parameter "MTK"
hcli contract create --name myErc20 --default erc20 --constructor-parameter "MyToken" --constructor-parameter "MTK"
2. Check balance
2. Check balance
hcli contract-erc20 balance-of --contract myErc20 --account 0.0.12345
hcli contract-erc20 balance-of --contract myErc20 --account 0.0.12345
3. Transfer via contract
3. Transfer via contract
hcli contract-erc20 transfer --contract myErc20 --to 0.0.67890 --value 50
undefinedhcli contract-erc20 transfer --contract myErc20 --to 0.0.67890 --value 50
undefinedBatch multiple token mints
批量铸造多个代币
bash
undefinedbash
undefined1. Create batch
1. Create batch
hcli batch create --name mintBatch --key 0.0.12345:302e...key...
hcli batch create --name mintBatch --key 0.0.12345:302e...key...
2. Add transactions to batch (using --batch flag on batchify-compatible commands)
2. Add transactions to batch (using --batch flag on batchify-compatible commands)
hcli token mint-ft --token MTK --amount 1000 --supply-key 0.0.12345:302e...key... --batch mintBatch
hcli token mint-ft --token MTK --amount 1000 --supply-key 0.0.12345:302e...key... --batch mintBatch
3. Execute batch
3. Execute batch
hcli batch execute --name mintBatch
undefinedhcli batch execute --name mintBatch
undefined