命令行 CLI

用户可以使用 CLI 查询并与 Interchain Accounts 模块交互。使用 --help 标志可查看可用命令:
simd query interchain-accounts --help
请注意,本节不会记录所有可用命令,只会补充说明那些无法在命令行文档中完整展开、且值得额外文档说明的命令。

控制端 Controller

用户可以查询并与控制端子模块交互。

查询 Query

query 命令允许用户查询控制端子模块。
simd query interchain-accounts controller --help

交易 Transactions

tx 命令允许用户与控制端子模块交互。
simd tx interchain-accounts controller --help

register

register 命令允许用户在指定连接上,为主机链注册一个链间账户。
simd tx interchain-accounts controller register [connection-id] [flags]
在注册过程中,会在控制端与主机端之间建立一个新通道。有两个可用标志会影响所创建的通道:
  • --version:用于指定通道的版本字符串(JSON 格式)。例如:{\"version\":\"ics27-1\",\"encoding\":\"proto3\",\"tx_type\":\"sdk_multi_msg\",\"controller_connection_id\":\"connection-0\",\"host_connection_id\":\"connection-0\"}。如果你希望指定链间账户数据包数据的编码格式(例如 proto3 或 proto3json),传入自定义版本字符串会很有用。如果未指定,控制端子模块会生成默认版本字符串。
  • --ordering:用于指定通道的排序方式。可选值为 order_ordered 和 order_unordered(未指定时默认为后者)。
示例:
simd tx interchain-accounts controller register connection-0 --ordering order_ordered --from cosmos1..

send-tx

send-tx 命令允许用户通过指定连接发送一笔交易,并在主机链上使用链间账户执行该交易。
simd tx interchain-accounts controller send-tx [connection-id] [path/to/packet_msg.json]
示例:
simd tx interchain-accounts controller send-tx connection-0 packet-data.json --from cosmos1..
下面给出了 packet-data.json 内容示例。CLI 处理器会将以下内容正确反序列化为 InterchainAccountPacketData。
{
  "type": "TYPE_EXECUTE_TX",
  "data": "CqIBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEoEBCkFjb3Ntb3MxNWNjc2hobXAwZ3N4MjlxcHFxNmc0em1sdG5udmdteXU5dWV1YWRoOXkybmM1emowc3psczVndGRkehItY29zbW9zMTBoOXN0YzV2Nm50Z2V5Z2Y1eGY5NDVuanFxNWgzMnI1M3VxdXZ3Gg0KBXN0YWtlEgQxMDAw",
  "memo": ""
}
请注意,data 字段是一个经过 base64 编码的字节串,其编码方式遵循通道握手期间约定的交易编码。 主机端子模块中还提供了一个辅助 CLI,可使用对端链的二进制程序生成该数据包数据 JSON。示例请参见下方的 generate-packet-data 命令。

主机端 Host

用户可以查询并与主机端子模块交互。

查询 Query

query 命令允许用户查询主机端子模块。
simd query interchain-accounts host --help

交易 Transactions

tx 命令允许用户与控制端子模块交互。
simd tx interchain-accounts host --help
generate-packet-data
generate-packet-data 命令允许用户为输入消息生成使用 protobuf 或 proto3 JSON 编码的链间账户数据包数据。随后,这些数据包数据可配合控制端子模块的 send-tx 命令 使用。可以使用 --encoding 标志指定编码格式(值必须为 proto3 或 proto3json);如果未指定,默认值为 proto3。可以使用 --memo 标志在链间账户数据包数据中包含备注字符串。
simd tx interchain-accounts host generate-packet-data [message]
示例:
simd tx interchain-accounts host generate-packet-data '[{
  "@type":"/cosmos.bank.v1beta1.MsgSend",
  "from_address":"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz",
  "to_address":"cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw",
  "amount": [
    {
      "denom": "stake",
      "amount": "1000"
    }
  ]
}]' --memo memo
该命令接受单个 sdk.Msg 或一组 sdk.Msg 列表,并将其编码到输出结果的 data 字段中。 输出示例:
{
  "type": "TYPE_EXECUTE_TX",
  "data": "CqIBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEoEBCkFjb3Ntb3MxNWNjc2hobXAwZ3N4MjlxcHFxNmc0em1sdG5udmdteXU5dWV1YWRoOXkybmM1emowc3psczVndGRkehItY29zbW9zMTBoOXN0YzV2Nm50Z2V5Z2Y1eGY5NDVuanFxNWgzMnI1M3VxdXZ3Gg0KBXN0YWtlEgQxMDAw",
  "memo": "memo"
}

gRPC

用户可以使用 gRPC 端点查询链间账户模块。

控制端 Controller

用户可以使用 gRPC 端点查询控制端子模块。

InterchainAccount

InterchainAccount 端点允许用户在特定连接上,查询某个 owner 对应的链间账户地址。
ibc.applications.interchain_accounts.controller.v1.Query/InterchainAccount
示例:
grpcurl -plaintext \
  -d '{"owner":"cosmos1..","connection_id":"connection-0"}' \
  localhost:9090 \
  ibc.applications.interchain_accounts.controller.v1.Query/InterchainAccount

Params

Params 端点允许用户查询当前控制端子模块参数。
ibc.applications.interchain_accounts.controller.v1.Query/Params
示例:
grpcurl -plaintext \
  localhost:9090 \
  ibc.applications.interchain_accounts.controller.v1.Query/Params

主机端 Host

用户可以使用 gRPC 端点查询主机端子模块。

Params

Params 端点允许用户查询当前主机端子模块参数。
ibc.applications.interchain_accounts.host.v1.Query/Params
示例:
grpcurl -plaintext \
  localhost:9090 \
  ibc.applications.interchain_accounts.host.v1.Query/Params

CLI

A user can query and interact with the Interchain Accounts module using the CLI. Use the --help flag to discover the available commands:
simd query interchain-accounts --help
Please not that this section does not document all the available commands, but only the ones that deserved extra documentation that was not possible to fit in the command line documentation.

Controller

A user can query and interact with the controller submodule.

Query

The query commands allow users to query the controller submodule.
simd query interchain-accounts controller --help

Transactions

The tx commands allow users to interact with the controller submodule.
simd tx interchain-accounts controller --help

register

The register command allows users to register an interchain account on a host chain on the provided connection.
simd tx interchain-accounts controller register [connection-id] [flags]
During registration a new channel is set up between controller and host. There are two flags available that influence the channel that is created:
  • --version to specify the (JSON-formatted) version string of the channel. For example: {\"version\":\"ics27-1\",\"encoding\":\"proto3\",\"tx_type\":\"sdk_multi_msg\",\"controller_connection_id\":\"connection-0\",\"host_connection_id\":\"connection-0\"}. Passing a custom version string is useful if you want to specify, for example, the encoding format of the interchain accounts packet data (either proto3 or proto3json). If not specified the controller submodule will generate a default version string.
  • --ordering to specify the ordering of the channel. Available options are order_ordered and order_unordered (default if not specified).
Example:
simd tx interchain-accounts controller register connection-0 --ordering order_ordered --from cosmos1..

send-tx

The send-tx command allows users to send a transaction on the provided connection to be executed using an interchain account on the host chain.
simd tx interchain-accounts controller send-tx [connection-id] [path/to/packet_msg.json]
Example:
simd tx interchain-accounts controller send-tx connection-0 packet-data.json --from cosmos1..
See below for example contents of packet-data.json. The CLI handler will unmarshal the following into InterchainAccountPacketData appropriately.
{
  "type": "TYPE_EXECUTE_TX",
  "data": "CqIBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEoEBCkFjb3Ntb3MxNWNjc2hobXAwZ3N4MjlxcHFxNmc0em1sdG5udmdteXU5dWV1YWRoOXkybmM1emowc3psczVndGRkehItY29zbW9zMTBoOXN0YzV2Nm50Z2V5Z2Y1eGY5NDVuanFxNWgzMnI1M3VxdXZ3Gg0KBXN0YWtlEgQxMDAw",
  "memo": ""
}
Note the data field is a base64 encoded byte string as per the tx encoding agreed upon during the channel handshake. A helper CLI is provided in the host submodule which can be used to generate the packet data JSON using the counterparty chain’s binary. See the generate-packet-data command for an example.

Host

A user can query and interact with the host submodule.

Query

The query commands allow users to query the host submodule.
simd query interchain-accounts host --help

Transactions

The tx commands allow users to interact with the controller submodule.
simd tx interchain-accounts host --help
generate-packet-data
The generate-packet-data command allows users to generate protobuf or proto3 JSON encoded interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule’s send-tx command. The --encoding flag can be used to specify the encoding format (value must be either proto3 or proto3json); if not specified, the default will be proto3. The --memo flag can be used to include a memo string in the interchain accounts packet data.
simd tx interchain-accounts host generate-packet-data [message]
Example:
simd tx interchain-accounts host generate-packet-data '[{
  "@type":"/cosmos.bank.v1beta1.MsgSend",
  "from_address":"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz",
  "to_address":"cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw",
  "amount": [
    {
      "denom": "stake",
      "amount": "1000"
    }
  ]
}]' --memo memo
The command accepts a single sdk.Msg or a list of sdk.Msgs that will be encoded into the outputs data field. Example output:
{
  "type": "TYPE_EXECUTE_TX",
  "data": "CqIBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEoEBCkFjb3Ntb3MxNWNjc2hobXAwZ3N4MjlxcHFxNmc0em1sdG5udmdteXU5dWV1YWRoOXkybmM1emowc3psczVndGRkehItY29zbW9zMTBoOXN0YzV2Nm50Z2V5Z2Y1eGY5NDVuanFxNWgzMnI1M3VxdXZ3Gg0KBXN0YWtlEgQxMDAw",
  "memo": "memo"
}

gRPC

A user can query the interchain account module using gRPC endpoints.

Controller

A user can query the controller submodule using gRPC endpoints.

InterchainAccount

The InterchainAccount endpoint allows users to query the controller submodule for the interchain account address for a given owner on a particular connection.
ibc.applications.interchain_accounts.controller.v1.Query/InterchainAccount
Example:
grpcurl -plaintext \
  -d '{"owner":"cosmos1..","connection_id":"connection-0"}' \
  localhost:9090 \
  ibc.applications.interchain_accounts.controller.v1.Query/InterchainAccount

Params

The Params endpoint users to query the current controller submodule parameters.
ibc.applications.interchain_accounts.controller.v1.Query/Params
Example:
grpcurl -plaintext \
  localhost:9090 \
  ibc.applications.interchain_accounts.controller.v1.Query/Params

Host

A user can query the host submodule using gRPC endpoints.

Params

The Params endpoint users to query the current host submodule parameters.
ibc.applications.interchain_accounts.host.v1.Query/Params
Example:
grpcurl -plaintext \
  localhost:9090 \
  ibc.applications.interchain_accounts.host.v1.Query/Params