源碼倉庫
一個基于 Node.js 和 TypeScript 構建的,用于與 TRON (波場) 區塊鏈進行交互的命令行工具 (CLI)。
本項目旨在提供一個簡單、可擴展的框架,讓開發者可以輕松地通過命令行調用 TRON 的 HTTP API,實現查詢鏈上信息、發送交易等操作。
? 功能特性
- 交互式命令行: 在終端中提供一個持續運行的交互式提示符。
- 清晰的架構: 命令邏輯、定義和主程序分離,易于理解和維護。
- 易于擴展: 添加新命令只需修改一個文件,無需改動核心邏輯。
- TypeScript 支持: 完整的類型定義,提供更好的開發體驗和代碼健壯性。
- 美觀的輸出: 使用
chalk
和figlet
美化輸出,使用console.table
格式化幫助信息。
🚀 安裝
源碼倉庫
📖 使用說明
tstroncli
程序啟動后,你可以輸入相應的命令并按回車鍵來執行。
可用命令
輸入 /help
可以查看所有支持的命令及其說明:
(index) | 方法名 | 中文解釋 | 英文解釋 |
---|---|---|---|
0 | createrandom | 創建 12 位的助記詞 | Create a 12-word mnemonic phrase |
1 | createaccount | 創建地址賬號 <未激活的新地址> | Create an address account |
2 | getaccount | 根據地址查詢賬戶信息。用法: getaccount <address: b58 | hex> |
3 | getaccountresources | 獲取賬號中的能量和帶寬資源。用法: getaccount <address: b58 | hex> |
4 | getgenesisblock | 獲取創世區塊(最早的區塊)信息 | Get information about the genesis block (earliest block) |
5 | getnowblock | 獲取最新的區塊信息 | Get information about the latest block |
6 | getblocknumber | 獲取最新的區塊信息 | Get the latest block number |
7 | getbalance | 獲取賬戶可用 TRX 余額。用法: getbalance <address: b58 | hex> |
8 | getbandwidth | 獲取賬戶可用帶寬余額。用法: getbandwidth <address: b58 | hex> |
9 | getbandwidthprices | 查詢歷史帶寬單價 | Query historical bandwidth unit prices |
10 | getblock | 通過區塊高度或區塊 ID 查詢區塊信息。用法: getblock <blockNumber | blockId |
11 | getblockbyhash | 通過區塊 ID 查詢區塊信息。用法: getblock | Query block information by block ID. Usage: getblock |
12 | getblockbynumber | 通過區塊高度查詢區塊信息。用法: getblockbynumber | Query block information by block height. Usage: getblockbynumber |
13 | getblockrange | 通過區塊高度區間查詢區塊信息。用法: getblockrange <startBlockNumber, endBlockNumber> | Query block information by block height range. Usage: getblockrange <startBlockNumber, endBlockNumber> |
14 | getblocktransactioncount | 檢索區塊內的交易數量。用法: getBlockTransactionCount <blockHeight | blockHash |
15 | getbrokerage | 獲取 SR 經紀傭金比例。用法: getbrokerage | Get the SR brokerage commission ratio. Usage: getbrokerage |
16 | getnodeinfo | 查詢節點信息 | Query node information |
17 | gettokenlistbyname | 通過代幣名稱 查詢 TRC10 代幣列表信息。用法: gettokenlistbyname | Query TRC10 token list information by token name. Usage: gettokenlistbyname |
18 | gettokenbyid | 通過代幣 id 查詢 TRC10 代幣信息。用法: gettokenbyid | Query TRC10 token information by token ID. Usage: gettokenbyid |
19 | gettokenfromid | 通過代幣 id 查詢 TRC10 代幣信息。用法: gettokenfromid | Query TRC10 token information by token ID. Usage: gettokenfromid |
20 | gettokensissuedbyaddress | 查詢賬戶的 TRC10 代幣發行信息。用法: gettokensissuedbyaddress <address: b58 | hex> |
21 | gettransaction | 通過交易 id 查詢交易信息。用法: gettransaction | Query transaction information by transaction ID. Usage: gettransaction |
22 | sendtoken | 交易 TRC10。用法: sendtoken <to: b58, amount: 1 (對應代幣最小單位), tokenID: 代幣 ID> | Transfer TRC10 tokens. Usage: sendtoken <to: b58, amount: 1 (smallest token unit), tokenID: token ID> |
23 | sendrawtransaction | 交易 TRX。用法: sendrawtransaction <to: b58, amount: 1 (單位: TRX)> | Transfer TRX. Usage: sendrawtransaction <to: b58, amount: 1 (unit: TRX)> |
24 | sendtrc20 | 交易 TRC20(注意:此交易會消耗 100TRX)。用法: sendtrc20 <to: b58, amount: 代幣數量, contractAddress: 合約地址> | Transfer TRC20 tokens (Note: consumes 100 TRX). Usage: sendtrc20 <to: b58, amount: token amount, contractAddress: contract address> |
25 | sign | 交易簽名(并未廣播上鏈)。用法: sign <from: b58, amount: 1 (單位 TRX), to: b58> | Sign a transaction (not broadcasted). Usage: sign <from: b58, amount: 1 (unit TRX), to: b58> |
26 | sendhextransaction | 交易簽名(將上一步的 sign 廣播上鏈)。用法: sendhextransaction | Broadcast a signed transaction. Usage: sendhextransaction |
27 | delegatebandwidth | 代理帶寬。用法: delegatebandwidth <to: b58, amount> | Delegate bandwidth. Usage: delegatebandwidth <to: b58, amount> |
28 | undelegatebandwidth | 回收帶寬。用法: undelegatebandwidth <from: b58, amount> | Undelegate bandwidth. Usage: undelegatebandwidth <from: b58, amount> |
29 | delegateenergy | 代理能量。用法: delegateenergy <to: b58, amount> | Delegate energy. Usage: delegateenergy <to: b58, amount> |
30 | undelegateenergy | 回收帶寬。用法: undelegateenergy <from: b58, amount> | Undelegate energy. Usage: undelegateenergy <from: b58, amount> |
31 | frommnemonic | 根據助記詞回復地址和私鑰 用法: frommnemonic | |
32 | suntotrx | sun to trx。用法: suntotrx | Convert sun to TRX. Usage: suntotrx |
33 | isaddress | isAddress。用法: isaddress <address: b58 | hex> |
34 | tobignumber | to big number。用法: tobignumber | Convert to big number. Usage: tobignumber |
35 | todecimal | to decimal: todecimal <value: 0x15> | Convert to decimal. Usage: todecimal <value: 0x15> |
項目還在開發中,命令尚未加完.如果你愿意,很樂意你參與其中加入新的命令
源碼倉庫