简介
stellar-repl
是一个基于 Node.js 的 Stellar 命令行交互工具,可以在命令行中方便地使用 Stellar 相关功能。
安装
使用 npm 包管理器进行安装:
npm install -g stellar-repl
使用方法
启动
命令行输入 stellar-repl
启动程序。启动后,会自动连接到 Stellar 的测试网络,用户可以在命令行中输入 Stellar 相关的命令进行操作。
命令列表
以下是 stellar-repl
支持的命令列表:
命令 | 描述 |
---|---|
help |
显示命令列表 |
account <address> |
获取指定地址的账户信息 |
balance <address> |
获取指定地址的余额 |
transaction <tx_hash> |
获取指定交易哈希的信息 |
send <source_address> <destination_address> <amount> |
从指定地址向目标地址发送指定数量的 XLM |
create-account |
创建一个 Stellar 钱包账户 |
exit |
退出程序 |
示例
下面是一些使用示例:
获取账户信息:
> account GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ { "_links": { "account": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ" }, "transactions": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/transactions{?cursor,limit,order}", "templated": true }, "operations": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/operations{?cursor,limit,order}", "templated": true }, "effects": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/effects{?cursor,limit,order}", "templated": true }, "offers": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/offers{?cursor,limit,order}", "templated": true }, "trades": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/trades{?cursor,limit,order}", "templated": true }, "data": { "href": "https://horizon-testnet.stellar.org/accounts/GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ/data/{key}", "templated": true } }, "id": "GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ", "paging_token": "5680404752840704", "account_id": "GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ", "sequence": "775565908448256", "subentry_count": 0, "thresholds": { "low_threshold": 1, "med_threshold": 2, "high_threshold": 3 }, "flags": { "auth_required": false, "auth_revocable": false }, "balances": [ { "balance": "9800.0000000", "buying_liabilities": "0.0000000", "selling_liabilities": "0.0000000", "asset_type": "native" } ], "signers": [ { "public_key": "GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ", "weight": 1, "key": "GA6X4PZC4IW4JKZYFZ7LQ2H6UOGS6LDZY4CCUH7CSKGMX6Y22TEBFZSZ", "type": "ed25519_public_key" } ], "data": {} }
发送 XLM:
> send GBJGTHERP36VFF47RQQKFT5F5ZJXBJ3BX3MQU5OB5NNLRGD7P5JNU557 GCGBJMAUDIOVNCAFCJSSDZYXUTZK7GB67Q2Q2H7PLJJGGAYJCWV5BANA 100 Transaction submitted in ledger 29126920, result code: txSUCCESS, hash: 7c06c20aa679d69dc3b3c1c01e9e9ec152d7bd95c695d393b7bcd1c8272e42d4, total time: 1437ms
总结
stellar-repl
可以方便地在命令行中使用 Stellar 相关功能。开发者们可以通过 stellar-repl
熟悉 Stellar 的命令行操作,快速进行开发、测试和调试。
来源:JavaScript中文网 ,转载请注明来源 本文地址:https://www.javascriptcn.com/post/60067381890c4f7277584236