当前位置: 首页 > news >正文

与 TRON (波场) 区块链进行交互的命令行工具 (CLI): tstroncli

源码仓库

在这里插入图片描述

一个基于 Node.js 和 TypeScript 构建的,用于与 TRON (波场) 区块链进行交互的命令行工具 (CLI)。

本项目旨在提供一个简单、可扩展的框架,让开发者可以轻松地通过命令行调用 TRON 的 HTTP API,实现查询链上信息、发送交易等操作。

✨ 功能特性

  • 交互式命令行: 在终端中提供一个持续运行的交互式提示符。
  • 清晰的架构: 命令逻辑、定义和主程序分离,易于理解和维护。
  • 易于扩展: 添加新命令只需修改一个文件,无需改动核心逻辑。
  • TypeScript 支持: 完整的类型定义,提供更好的开发体验和代码健壮性。
  • 美观的输出: 使用 chalkfiglet 美化输出,使用 console.table 格式化帮助信息。

🚀 安装

源码仓库

📖 使用说明

tstroncli程序启动后,你可以输入相应的命令并按回车键来执行。

可用命令

输入 /help 可以查看所有支持的命令及其说明:
在这里插入图片描述

(index)方法名中文解释英文解释
0createrandom创建 12 位的助记词Create a 12-word mnemonic phrase
1createaccount创建地址账号 <未激活的新地址>Create an address account
2getaccount根据地址查询账户信息。用法: getaccount <address: b58hex>
3getaccountresources获取账号中的能量和带宽资源。用法: getaccount <address: b58hex>
4getgenesisblock获取创世区块(最早的区块)信息Get information about the genesis block (earliest block)
5getnowblock获取最新的区块信息Get information about the latest block
6getblocknumber获取最新的区块信息Get the latest block number
7getbalance获取账户可用 TRX 余额。用法: getbalance <address: b58hex>
8getbandwidth获取账户可用带宽余额。用法: getbandwidth <address: b58hex>
9getbandwidthprices查询历史带宽单价Query historical bandwidth unit prices
10getblock通过区块高度或区块 ID 查询区块信息。用法: getblock <blockNumberblockId
11getblockbyhash通过区块 ID 查询区块信息。用法: getblock Query block information by block ID. Usage: getblock
12getblockbynumber通过区块高度查询区块信息。用法: getblockbynumber Query block information by block height. Usage: getblockbynumber
13getblockrange通过区块高度区间查询区块信息。用法: getblockrange <startBlockNumber, endBlockNumber>Query block information by block height range. Usage: getblockrange <startBlockNumber, endBlockNumber>
14getblocktransactioncount检索区块内的交易数量。用法: getBlockTransactionCount <blockHeightblockHash
15getbrokerage获取 SR 经纪佣金比例。用法: getbrokerage
Get the SR brokerage commission ratio. Usage: getbrokerage
16getnodeinfo查询节点信息Query node information
17gettokenlistbyname通过代币名称 查询 TRC10 代币列表信息。用法: gettokenlistbyname Query TRC10 token list information by token name. Usage: gettokenlistbyname
18gettokenbyid通过代币 id 查询 TRC10 代币信息。用法: gettokenbyid Query TRC10 token information by token ID. Usage: gettokenbyid
19gettokenfromid通过代币 id 查询 TRC10 代币信息。用法: gettokenfromid Query TRC10 token information by token ID. Usage: gettokenfromid
20gettokensissuedbyaddress查询账户的 TRC10 代币发行信息。用法: gettokensissuedbyaddress <address: b58hex>
21gettransaction通过交易 id 查询交易信息。用法: gettransaction Query transaction information by transaction ID. Usage: gettransaction
22sendtoken交易 TRC10。用法: sendtoken <to: b58, amount: 1 (对应代币最小单位), tokenID: 代币 ID>Transfer TRC10 tokens. Usage: sendtoken <to: b58, amount: 1 (smallest token unit), tokenID: token ID>
23sendrawtransaction交易 TRX。用法: sendrawtransaction <to: b58, amount: 1 (单位: TRX)>Transfer TRX. Usage: sendrawtransaction <to: b58, amount: 1 (unit: TRX)>
24sendtrc20交易 TRC20(注意:此交易会消耗 100TRX)。用法: sendtrc20 <to: b58, amount: 代币数量, contractAddress: 合约地址>Transfer TRC20 tokens (Note: consumes 100 TRX). Usage: sendtrc20 <to: b58, amount: token amount, contractAddress: contract address>
25sign交易签名(并未广播上链)。用法: sign <from: b58, amount: 1 (单位 TRX), to: b58>Sign a transaction (not broadcasted). Usage: sign <from: b58, amount: 1 (unit TRX), to: b58>
26sendhextransaction交易签名(将上一步的 sign 广播上链)。用法: sendhextransaction Broadcast a signed transaction. Usage: sendhextransaction
27delegatebandwidth代理带宽。用法: delegatebandwidth <to: b58, amount>Delegate bandwidth. Usage: delegatebandwidth <to: b58, amount>
28undelegatebandwidth回收带宽。用法: undelegatebandwidth <from: b58, amount>Undelegate bandwidth. Usage: undelegatebandwidth <from: b58, amount>
29delegateenergy代理能量。用法: delegateenergy <to: b58, amount>Delegate energy. Usage: delegateenergy <to: b58, amount>
30undelegateenergy回收带宽。用法: undelegateenergy <from: b58, amount>Undelegate energy. Usage: undelegateenergy <from: b58, amount>
31frommnemonic根据助记词回复地址和私钥 用法: frommnemonic
32suntotrxsun to trx。用法: suntotrx Convert sun to TRX. Usage: suntotrx
33isaddressisAddress。用法: isaddress <address: b58hex>
34tobignumberto big number。用法: tobignumber Convert to big number. Usage: tobignumber
35todecimalto decimal: todecimal <value: 0x15>Convert to decimal. Usage: todecimal <value: 0x15>

项目还在开发中,命令尚未加完.如果你愿意,很乐意你参与其中加入新的命令

源码仓库

http://www.dtcms.com/a/298690.html

相关文章:

  • 为什么会有 CompletableFuture?它是为了解决什么痛点的?
  • Pandas 处理缺失数据
  • 为 GitHub Pages 站点配置自定义域(Windows)(Linked Page)
  • Android Ntp系统校时流程
  • C#(基本语法)
  • 人工智能冗余:大语言模型为何有时表现不佳(以及我们能做些什么)
  • 推荐系统多目标排序模型以及融合策略
  • WebSocket详解
  • ClickHouse 高性能实时分析数据库-物化视图篇
  • 学习笔记《区块链技术与应用》第二天 共识机制
  • 亚马逊阿联酋推“Amazon Bazaar”:解码中东电商市场的本地化突围
  • 线程安全的单例模式
  • 基于米尔瑞芯微RK3576开发板部署运行TinyMaix:超轻量级推理框架
  • 2025年高防IP全景解读:从流量清洗到智能防御的核心跃迁
  • mib2c --生成标量数据对应c文件
  • NOIP普及组系列【2015】 P2669 [NOIP 2015 普及组] 金币题解
  • GPU 驱动安装升级测试
  • 避开算力坑!无人机桥梁检测场景下YOLO模型选型指南
  • Minio Docker 集群部署
  • 【阅读整理】野火ADC_AD7192模块资料
  • haproxy七层代理(超详细)
  • 算法讲解--查找总价值为目标值的两个商品
  • MyBatisPlus简介与基本CRUD
  • 域名服务器的作用是什么
  • 【js(7)创建对象的三种写法】
  • Node.js(三)之Express
  • Three.js 动画系统入门:Tween.js 与 AnimationMixer 的使用
  • 习题5.6 “数学黑洞“
  • Java研学-RabbitMQ(二)
  • 亚德诺半导体AD8612ARUZ-REEL双通道精密运算放大器,0.5μV超低失调电压+0.02μV/°C温漂!