mcpField
C
cardano-cli-transactions

cardano-cli-transactions

github.com/flux-point-studios其他839 次安装5 周前更新
代码仓库

关于 cardano-cli-transactions

面向使用 `cardano-cli` 构建 Cardano 交易的指导技能,提供命令模板和说明,但不会执行交易;实际执行交由 `cardano-cli-transactions-operator`。

主要功能

  1. 01交易构建命令模板
  2. 02UTxO 选择与找零说明
  3. 03代币和元数据示例
  4. 04网络确认与手续费指导
  5. 05Docker 包装脚本备用方案

适用场景

  1. 01学习 Cardano 交易构建模式
  2. 02拟定 ADA 转账命令步骤
  3. 03准备多输出或代币交易
  4. 04本地未安装 cardano-cli 时构造命令

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/flux-point-studios/cardano-agent-skills --skill cardano-cli-transactions

安装后在 Claude Code 中输入/cardano-cli-transactions确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

reference/
docker-fallback.md
tx-send-ada.md
scripts/
cardano-cli.sh

详细介绍

cardano-cli-transactions

这是一项指导技能。 提供模板和说明。如需执行,请使用 cardano-cli-transactions-operator。

适用场景

  • 学习交易构建模式
  • 了解 UTxO 选择和找零
  • 获取各种交易类型的命令模板

操作规则(必须遵守)

  • 提供命令前,先确认网络(mainnet/preprod/preview)
  • 绝不执行命令——只提供模板
  • 始终包含手续费处理和找零
  • 包含验证步骤

Docker 备用模式

如果本地未安装 cardano-cli,请使用此技能文件夹中的包装脚本,在 Docker 中运行 cardano-cli(Cardano 节点容器映像包含该 CLI)。

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> 覆盖映像。

工作流模板

简单 ADA 转账
# 1. Query sender UTxOs
cardano-cli conway query utxo \
  --address <sender-addr> \
  --testnet-magic 1

# 2. Get protocol parameters
cardano-cli conway query protocol-parameters \
  --testnet-magic 1 \
  --out-file pparams.json

# 3. Build transaction
cardano-cli conway transaction build \
  --testnet-magic 1 \
  --tx-in <utxo-hash>#<index> \
  --tx-out <recipient>+<amount-lovelace> \
  --change-address <sender-addr> \
  --out-file tx.unsigned

# 4. Sign
cardano-cli conway transaction sign \
  --tx-file tx.unsigned \
  --signing-key-file payment.skey \
  --testnet-magic 1 \
  --out-file tx.signed

# 5. Submit
cardano-cli conway transaction submit \
  --testnet-magic 1 \
  --tx-file tx.signed

# 6. Verify
cardano-cli conway transaction txid --tx-file tx.signed
多输出交易
cardano-cli conway transaction build \
  --testnet-magic 1 \
  --tx-in <utxo>#<index> \
  --tx-out <addr1>+<amount1> \
  --tx-out <addr2>+<amount2> \
  --tx-out <addr3>+<amount3> \
  --change-address <sender> \
  --out-file tx.unsigned
带原生代币
cardano-cli conway transaction build \
  --testnet-magic 1 \
  --tx-in <utxo>#<index> \
  --tx-out "<recipient>+<lovelace>+<amount> <policy-id>.<asset-name>" \
  --change-address <sender> \
  --out-file tx.unsigned
带元数据
cardano-cli conway transaction build \
  --testnet-magic 1 \
  --tx-in <utxo>#<index> \
  --tx-out <recipient>+<amount> \
  --change-address <sender> \
  --metadata-json-file metadata.json \
  --out-file tx.unsigned

示例

示例:在 preprod 上发送 10 ADA

用户请求:“向 addr_test1qz... 发送 10 ADA”

回复:

# === Send 10 ADA on Preprod ===

# Setup
SENDER_ADDR="addr_test1..."
RECIPIENT="addr_test1qz..."
AMOUNT=10000000  # 10 ADA in lovelace

# 1. Query UTxOs
cardano-cli conway query utxo \
  --address $SENDER_ADDR \
  --testnet-magic 1

# 2. Build (using first UTxO with sufficient funds)
cardano-cli conway transaction build \
  --testnet-magic 1 \
  --tx-in <paste-utxo-here>#0 \
  --tx-out "$RECIPIENT+$AMOUNT" \
  --change-address $SENDER_ADDR \
  --out-file tx.unsigned

# 3. Sign
cardano-cli conway transaction sign \
  --tx-file tx.unsigned \
  --signing-key-file payment.skey \
  --testnet-magic 1 \
  --out-file tx.signed

# 4. Submit (use operator skill or run manually)
# cardano-cli conway transaction submit --testnet-magic 1 --tx-file tx.signed

交易包文件夹结构

tx-20240115-143022/
├── pparams.json       # Protocol parameters used
├── tx.unsigned        # Unsigned transaction
├── tx.signed          # Signed transaction
├── utxos.json         # Input UTxOs at build time
└── commands.log       # Commands executed

安全 / 密钥处理

  • 绝不泄露签名密钥
  • 仔细核验收款地址
  • 在 mainnet 上:先进行小额测试转账
  • 保留交易包作为审计记录

参考

  • shared/PRINCIPLES.md
  • cardano-cli-transactions-operator(用于执行)

评论

支持 Markdown