cosmos-sdk: How to get readable transactions of a block from API?

Summary

I cann’t get readable transactions of one block from API http://localhost:26657/block?height=3, because txs params is encoded data.

GET https://localhost:1317/blocks/3

{
    "jsonrpc": "2.0",
    "block": {
      ......................
      "data": {
        "txs": [
          "+wHwYl3uCnjqK1CUChSzAR1m0CdB0hEH42oUyDxRsnM5pRIlFiTeZCATlR1nIY5WzOSt1kaRXBpLJPJXfC4Xhj8LaWUYH8F4ThooCh8KBGh0dHASCTEwLjAuMC45NhoJbG9jYWxob3N0IMA+EgVOT0RFMSILCgRBSU9aEgMxMDASDwoJCgRBSU9aEgE1EMCaDBpqCibrWumHIQKQPb8sahooV/qJRP2ikxPxuSTFp+pcJ1HPTAXd1wWzCRJAQxAQn1254DoPTXQ/rsNsKJ/rNeenGPYufv5VcKVlcf9d8BHI8MBBWL+jSTgAavWYrDBHLaDP7ZAr0rDbp1ldbg=="
        ]
      },
      ......................
    }
  }
}

Problem Definition

On my web client, I need to get list transactions (ids or details) of one block? Did we have it?

Proposal

Can I get readable transactions of a block through RPC API?

Another solution I found is search txs: https://localhost:1317/txs?tx.height=3 but get error because of tags must be string when search tx https://github.com/cosmos/cosmos-sdk/blob/dbfaa4a514fd70297d4a415ce2b6b46b3f6836a0/client/tx/search.go#L174

So, I got an error

TxSearch: Response error: RPC error -32603 - Internal error: interface conversion: interface {} is string, not int64

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

This feature isn’t currently available. We have an open issue for implementation here: https://github.com/cosmos/cosmos-sdk/issues/466

Going to close this issue in favor of that one.

bz := cdc.MustMarshalBinaryLengthPrefixed(tx)
hash := tmcrypto.Sha256(bz)
// ...

What is the problem here? The height query gives you the transactions as you’ve shown. You need to Base64 decode to get the raw binary blob and then use a codec to deserialize into a proper Tx.