cardano-cli-staking

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cardano-cli-staking

cardano-cli-staking

This is a guidance skill. Provides templates and explanations. For execution, use
cardano-cli-staking-operator
.
这是一个指南类技能,提供操作模板和说明。如需执行操作,请使用
cardano-cli-staking-operator

When to use

适用场景

  • Learning stake key registration and delegation
  • Understanding rewards withdrawal
  • Getting command templates for staking operations
  • 学习质押密钥注册与委托操作
  • 了解奖励提取流程
  • 获取质押操作的命令模板

Operating rules (must follow)

操作规则(必须遵守)

  • Confirm network before providing commands
  • Never execute—only provide templates
  • Include deposit/fee information
  • Verify pool ID from multiple sources
  • 提供命令前请确认网络环境
  • 绝不执行操作,仅提供模板
  • 包含押金/手续费信息
  • 从多渠道验证矿池ID

Docker fallback mode

Docker fallback模式

If
cardano-cli
is not installed locally, use the wrapper script in this skill folder to run cardano-cli inside Docker (the Cardano node container images include the CLI).
bash
chmod +x {baseDir}/scripts/cardano-cli.sh
{baseDir}/scripts/cardano-cli.sh version
Notes:
  • The wrapper mounts your current directory into the container as
    /work
    so files like
    pparams.json
    ,
    tx.body
    ,
    datum.json
    work normally.
  • If you have a local node socket, set
    CARDANO_NODE_SOCKET_PATH
    before running so
    query
    commands work.
  • Override the image with
    CARDANO_DOCKER_IMAGE=ghcr.io/intersectmbo/cardano-node:<tag>
    .
如果本地未安装
cardano-cli
,可使用本技能文件夹中的包装脚本在Docker内运行cardano-cli(Cardano节点容器镜像已包含该CLI工具)。
bash
chmod +x {baseDir}/scripts/cardano-cli.sh
{baseDir}/scripts/cardano-cli.sh version
注意事项:
  • 该包装脚本会将当前目录挂载到容器的
    /work
    路径下,因此
    pparams.json
    tx.body
    datum.json
    等文件可正常使用。
  • 若本地存在节点套接字,请在运行前设置
    CARDANO_NODE_SOCKET_PATH
    环境变量,以确保
    query
    命令正常工作。
  • 可通过
    CARDANO_DOCKER_IMAGE=ghcr.io/intersectmbo/cardano-node:<tag>
    指定镜像版本。

Key concepts

核心概念

Stake addresses vs payment addresses

质押地址 vs 支付地址

  • Payment address: Holds funds, used for spending
  • Stake address: Controls delegation, receives rewards
  • Base address: Combines both (most common)
  • 支付地址:存储资金,用于转账支出
  • 质押地址:控制委托操作,接收奖励
  • 基础地址:同时包含支付与质押功能(最常用)

Deposits

押金

  • Stake key registration: ~2 ADA deposit (refundable)
  • Pool registration: ~500 ADA deposit (refundable)
  • 质押密钥注册:约2 ADA押金(可退还)
  • 矿池注册:约500 ADA押金(可退还)

Workflow templates

工作流模板

Check stake status

查看质押状态

bash
undefined
bash
undefined

Derive stake address

Derive stake address

cardano-cli conway stake-address build
--stake-verification-key-file stake.vkey
--testnet-magic 1
--out-file stake.addr
cardano-cli conway stake-address build
--stake-verification-key-file stake.vkey
--testnet-magic 1
--out-file stake.addr

Query status

Query status

cardano-cli conway query stake-address-info
--testnet-magic 1
--address $(cat stake.addr)
undefined
cardano-cli conway query stake-address-info
--testnet-magic 1
--address $(cat stake.addr)
undefined

Register stake key

注册质押密钥

bash
undefined
bash
undefined

1. Create registration certificate

1. Create registration certificate

cardano-cli conway stake-address registration-certificate
--stake-verification-key-file stake.vkey
--out-file stake-reg.cert
cardano-cli conway stake-address registration-certificate
--stake-verification-key-file stake.vkey
--out-file stake-reg.cert

2. Build transaction with certificate

2. Build transaction with certificate

cardano-cli conway transaction build
--testnet-magic 1
--tx-in <utxo>#<index>
--change-address <payment-addr>
--certificate-file stake-reg.cert
--out-file tx.unsigned
cardano-cli conway transaction build
--testnet-magic 1
--tx-in <utxo>#<index>
--change-address <payment-addr>
--certificate-file stake-reg.cert
--out-file tx.unsigned

3. Sign with BOTH keys

3. Sign with BOTH keys

cardano-cli conway transaction sign
--tx-file tx.unsigned
--signing-key-file payment.skey
--signing-key-file stake.skey
--testnet-magic 1
--out-file tx.signed
cardano-cli conway transaction sign
--tx-file tx.unsigned
--signing-key-file payment.skey
--signing-key-file stake.skey
--testnet-magic 1
--out-file tx.signed

4. Submit

4. Submit

cardano-cli conway transaction submit
--testnet-magic 1
--tx-file tx.signed
undefined
cardano-cli conway transaction submit
--testnet-magic 1
--tx-file tx.signed
undefined

Delegate to pool

委托至矿池

bash
undefined
bash
undefined

1. Create delegation certificate

1. Create delegation certificate

cardano-cli conway stake-address stake-delegation-certificate
--stake-verification-key-file stake.vkey
--stake-pool-id pool1...
--out-file delegation.cert
cardano-cli conway stake-address stake-delegation-certificate
--stake-verification-key-file stake.vkey
--stake-pool-id pool1...
--out-file delegation.cert

2. Build, sign (both keys), submit

2. Build, sign (both keys), submit

Same pattern as registration

Same pattern as registration

undefined
undefined

Withdraw rewards

提取奖励

bash
undefined
bash
undefined

1. Check rewards balance

1. Check rewards balance

cardano-cli conway query stake-address-info
--testnet-magic 1
--address $(cat stake.addr)
cardano-cli conway query stake-address-info
--testnet-magic 1
--address $(cat stake.addr)

2. Build withdrawal tx

2. Build withdrawal tx

cardano-cli conway transaction build
--testnet-magic 1
--tx-in <utxo>#<index>
--withdrawal $(cat stake.addr)+<reward-lovelace>
--change-address <payment-addr>
--out-file tx.unsigned
cardano-cli conway transaction build
--testnet-magic 1
--tx-in <utxo>#<index>
--withdrawal $(cat stake.addr)+<reward-lovelace>
--change-address <payment-addr>
--out-file tx.unsigned

3. Sign with BOTH keys, submit

3. Sign with BOTH keys, submit

undefined
undefined

De-register stake key (get deposit back)

注销质押密钥(取回押金)

bash
cardano-cli conway stake-address deregistration-certificate \
  --stake-verification-key-file stake.vkey \
  --out-file stake-dereg.cert
bash
cardano-cli conway stake-address deregistration-certificate \
  --stake-verification-key-file stake.vkey \
  --out-file stake-dereg.cert

Build tx with certificate, sign, submit

Build tx with certificate, sign, submit

undefined
undefined

Examples

示例

Example: Delegate to a pool

示例:委托至矿池

User request: "Delegate my stake to pool1abc..."
Response:
bash
undefined
用户请求:“将我的质押委托至pool1abc...”
响应
bash
undefined

=== Delegate to Pool ===

=== Delegate to Pool ===

POOL_ID="pool1abc..." STAKE_VKEY="stake.vkey" PAYMENT_ADDR=$(cat base.addr)
POOL_ID="pool1abc..." STAKE_VKEY="stake.vkey" PAYMENT_ADDR=$(cat base.addr)

1. Verify pool exists

1. Verify pool exists

cardano-cli conway query stake-pools --testnet-magic 1 | grep $POOL_ID
cardano-cli conway query stake-pools --testnet-magic 1 | grep $POOL_ID

2. Create delegation certificate

2. Create delegation certificate

cardano-cli conway stake-address stake-delegation-certificate
--stake-verification-key-file $STAKE_VKEY
--stake-pool-id $POOL_ID
--out-file delegation.cert
cardano-cli conway stake-address stake-delegation-certificate
--stake-verification-key-file $STAKE_VKEY
--stake-pool-id $POOL_ID
--out-file delegation.cert

3. Build transaction

3. Build transaction

cardano-cli conway transaction build
--testnet-magic 1
--tx-in <your-utxo>#0
--change-address $PAYMENT_ADDR
--certificate-file delegation.cert
--out-file tx.unsigned
cardano-cli conway transaction build
--testnet-magic 1
--tx-in <your-utxo>#0
--change-address $PAYMENT_ADDR
--certificate-file delegation.cert
--out-file tx.unsigned

4. Sign with both keys

4. Sign with both keys

cardano-cli conway transaction sign
--tx-file tx.unsigned
--signing-key-file payment.skey
--signing-key-file stake.skey
--testnet-magic 1
--out-file tx.signed
cardano-cli conway transaction sign
--tx-file tx.unsigned
--signing-key-file payment.skey
--signing-key-file stake.skey
--testnet-magic 1
--out-file tx.signed

5. Submit (use operator skill)

5. Submit (use operator skill)

Delegation takes effect at next epoch boundary

Delegation takes effect at next epoch boundary

undefined
undefined

Safety / key handling

安全与密钥管理

  • Verify pool ID from multiple sources (adapools, cexplorer)
  • Staking never risks your principal
  • Delegation can be changed anytime
  • Rewards accumulate until withdrawn
  • 从多渠道验证矿池ID(如adapools、cexplorer)
  • 质押操作不会危及你的本金
  • 委托操作可随时更改
  • 奖励会累积至提取时

References

参考资料

  • shared/PRINCIPLES.md
  • cardano-cli-staking-operator
    (for execution)
  • shared/PRINCIPLES.md
  • cardano-cli-staking-operator
    (用于执行操作)