Skip to content

IBC: ChannelID and Denom Relationship

Yang SONG edited this page Dec 14, 2021 · 3 revisions

IBC: ChannelID and Denom Relationship

A few pages are related to this issue.

  • IBC Channel Detail Page, Messages section
  • Transactions List Page
  • Account Detail Page, Transactions section

Difference in API Responses

Messages of a specific IBC Channel

For Messages on a specific IBC Channel, api/v1/ibc/channels/<channel-id>/messages

e.g. https://crypto.org/explorer/api/v1/ibc/channels/channel-24/messages?pagination=offset&page=1&limit=10&channelId=channel-24&pageSize=10

The full message parsed by indexing server is under response.result[0].message.

Warning!

For this API, you might find three denoms unber each result entry.

  • response.result[0].denom: Not recommend, could be in ibc/xxx format. Will fix it soon.
  • response.result[0].message.params.token.denom: Not recommend, could be in ibc/xxx format.
  • response.result[0].message.params.packetData.denom: USE THIS! Always in [<port-id>/<channel-id>/]<original-denom> format.

Messages under a specific transaction

For Transactions list, api/v1/transactions

e.g. https://crypto.org/explorer/api/v1/transactions/005E3859616C307A105F3C30A2C6AA33D99AE918769BDF6F8BB1CABC24A9CEC8

The full message parsed by indexing server is under response.result[0].messages[X].content.

Messages under a specific account

For Account transaction list: api/v1/accounts/<account>/transactions

e.g. https://crypto.org/explorer/api/v1/accounts/cro13s4qk72a06vlpeyxw2znlfs6gzkhwf9lfzf4yd/transactions?pagination=offset&page=1&memo&limit=8&order=height.desc

The full message parsed by indexing server is under response.result[0].messages[X].content.

Params

The most important information for a message, is under the params key for each full message.

In the following sections, I will list the denom formats in different messages' params key.

More examples on IBC full message is available to download here: https://github.com/crypto-com/chain-indexing/issues/645#issuecomment-993101357.

MsgTransfer

Two denoms available under params.

Transfer Native Tokens

  • params.token.denom:
    • <original-denom>
  • params.packetData.denom (Recommend):
    • <original-denom>

Transfer IBC Tokens

  • params.token.denom:
    • ibc/XXXX
  • params.packetData.denom (Recommend):
    • <source-port>/<source-channel>/<original-denom>
    • It is using port and channel on this chain.

MsgRecvPacket

Two denoms available under params.

Receive IBC Tokens (Receive Counterparty Native Tokens)

  • params.maybeMsgTransfer.denom:
    • <counterparty-original-denom>
  • params.maybeMsgTransfer.maybeDenominationTrace.denom:
    • ibc/XXXX = ibc/ + sha256(<destination-port>/<destination-channel>/<counterparty-original-denom>)
    • It is using port and channel on this chain.

Receive Native Tokens (Native Tokens sent back from counterparty)

  • params.maybeMsgTransfer.denom:
    • <source-port>/<source-channel>/<original-denom>
    • It is using port and channel on counterparty chain.

MsgAcknowledgement

Acknowledge Native Tokens Transfer

  • params.maybeMsgTransfer.denom:
    • <original-denom>

Acknowledge IBC Tokens Transfer

  • params.maybeMsgTransfer.denom:
    • <source-port>/<source-channel>/<original-denom>
    • It is using port and channel on this chain.

MsgTimeout

Timeout Native Tokens Transfer

  • params.maybeTransfer.refundDenom:
    • <orignal-denom>

Timeout IBC Tokens Transfer

  • params.maybeTransfer.refundDenom:
    • <source-port>/<source-channel>/<original-denom>
    • It is using port and channel on this chain.

MsgTimeout on Explorer example: https://crypto.org/explorer/tx/DBE9B18CD42387C09AA52242F01CBD0003B95292E5BA015187FCCDAE637DFFBD

Its corresponding MsgTransfer on Explorer: https://crypto.org/explorer/tx/005E3859616C307A105F3C30A2C6AA33D99AE918769BDF6F8BB1CABC24A9CEC8

MsgTimeoutOnClose

I can't find any real example for this. But we could just apply the same logic as MsgTimeout.

Summary

For display the above mentioned IBC messages, I suggest to bypass the ibc/xxx denom format and to only use the denom in [<port-id>/<channel-id>/]<original-denom> format.

As every message contains a denom that are in [<port-id>/<channel-id>/]<original-denom> format, which is more user friendly.

However, for account balance, the API response could still have ibc/xxx format denom. As it is from Cosmos RPC and not controlled by our indexing server.