1个不稳定版本
0.1.0 | 2024年5月13日 |
---|
在#cosmos中排名91
38KB
847 行
Cosmos CLI
Cosmos CLI是一个简单的命令行工具,提供有用的命令来获取关于Cosmos区块链生态系统中各种资源的信息。
安装
首先确保您已经安装了较新的rust/cargo版本。然后,在您的shell中执行以下命令
$ cargo install cosmos-cli
用法
要获取有关可用命令的信息,请运行
$ cosmos_cli --help
Cosmos CLI
Usage: cosmos-cli [OPTIONS] <COMMAND>
Commands:
info Get information about resources in the Cosmos ecosystem
list List resources in the Cosmos ecosystem
astroport Get information about Astroport resources
help Print this message or the help of the given subcommand(s)
Options:
-o, --output <OUTPUT> Output format [default: plain] [possible values: plain, json]
-h, --help Print help
-V, --version Print version
要获取Cosmos生态系统中所有链的列表
$ cosmos-cli list chains
8ball
acrechain
agoric
aioz
...
要获取格式化为JSON的结果,请使用--output
参数
$ cosmos-cli --output json list chains
["8ball","acrechain","agoric","aioz","akash","akiro", "andromeda","andromeda1", ... ,"xpla","zetachain"]
与jq结合时,JSON格式的输出非常方便。
输出将以表格格式显示info
命令。例如,要显示CosmosHub的ATOM代币的信息
$ cosmos-cli info asset cosmoshub atom
+--------------+--------------+
| base | uatom |
+--------------+--------------+
| coingecko_id | cosmos |
+--------------+--------------+
| decimals | 0 |
+--------------+--------------+
| display | atom |
+--------------+----------+---+
...
还有更多有用的命令,下一节将详细介绍所有这些命令。如果您看到缺失的命令,请提交PR!:)
可用子命令
cosmos-cli info
Get information about resources in the Cosmos ecosystem
Usage: cosmos-cli info [OPTIONS] <COMMAND>
Commands:
chain Get information about a specific chain in the Cosmos ecosystem
assets Get information about all assets of a specific chain in the Cosmos ecosystem
asset Get information about a specific asset of a specific chain in the Cosmos ecosystem
path Get information about all IBC paths in the Cosmos ecosystem
示例
$ cosmos-cli info path neutron stargaze
+----------+---------------+---------------------+
| chain_1 | chain_name | neutron |
| +---------------+---------------------+
| | client_id | 07-tendermint-31 |
| +---------------+---------------------+
| | connection_id | connection-23 |
+----------+---------------+---------------------+
| chain_2 | chain_name | stargaze |
| +---------------+---------------------+
| | client_id | 07-tendermint-283 |
| +---------------+---------------------+
| | connection_id | connection-211 |
+----------+----------+----+-------+-------------+
| channels | chain_1 | channel_id | channel-18 |
| | +------------+-------------+
| | | port_id | transfer |
| +----------+------------+-------------+
| | chain_2 | channel_id | channel-191 |
| | +------------+-------------+
| | | port_id | transfer |
| +----------+------------+-------------+
| | ordering | unordered |
| +----------+-----------+--------------+
| | tags | preferred | true |
| | +-----------+--------------+
| | | status | live |
| +----------+-----------+--------------+
| | version | ics20-1 |
+----------+----------+--------------------------+
cosmos-cli list
List resources in the Cosmos ecosystem
Usage: cosmos-cli list [OPTIONS] <COMMAND>
Commands:
chains List all chains in the Cosmos ecosystem
assets List assets for a specific chain in the Cosmos ecosystem
paths List all IBC paths in the Cosmos ecosystem
示例
$ cosmos-cli list assets osmosis | wc -l
344
$ cosmos-cli list assets osmosis
OSMO
ION
USDC.axl
ETH
WBTC.axl
USDT.axl
DAI
BUSD
ATOM
CRO
BNB
MATIC
AVAX
...
cosmos-cli astroport
Get information about Astroport resources
Usage: cosmos-cli astroport [OPTIONS] <COMMAND>
Commands:
native-tokens List native tokens on Astroport
pairs List pairs on Astroport
pair Get information about a specific pair on Astroport
pool Get information about a specific pool on Astroport
示例
获取Astroport上STARS/NTRN池的信息
$ cosmos-cli astroport pool ibc/A139C0E0B5E87CBA8EAEEB12B9BEE13AC7C814CFBBFA87BBCADD67E31003466C untrn
+-------------+--------+---------------------------------------------------------------------------------------------+
| assets | amount | 4458687253 |
| +--------+--------------+-------+----------------------------------------------------------------------+
| | info | native_token | denom | ibc/A139C0E0B5E87CBA8EAEEB12B9BEE13AC7C814CFBBFA87BBCADD67E31003466C |
| +--------+--------------+-------+----------------------------------------------------------------------+
| | amount | 126374360 |
| +--------+--------------+-------+----------------------------------------------------------------------+
| | info | native_token | denom | untrn |
+-------------+--------+--------------+-------+----------------------------------------------------------------------+
| total_share | 749090358 |
+-------------+------------------------------------------------------------------------------------------------------+
许可
Cosmos CLI在Apache 2下许可。
依赖关系
~12–25MB
~367K SLoC