Closed cryptosystems6300 closed 4 months ago
We can do that. There is two options : we proxy the request (but I would rather avoid having the server to have to be aware of the node) or we recalculate the balance using the transactions collected.
I like the idea of recalculating the balance using the collected transactions. This is also in line with something that I would like to add at some point: an endpoint for reconciling the balance from the database vs. querying the node.
I've poked around the schema a bit and it's not immediately clear to me how one would fully calculate the balance for an address. Not all of the different transaction views provide an amount
column (e.g. tx_ibc
) although, perhaps that's not relevant if we limit the scope to native token only.
Also, how do shielded transactions factor in? Are those simply excluded from the reported balance?
To calculate the balance, we must not forget about the tx fees on all transaction types...
Lets go with option 2 then.
It is not entirely clear for me how to do it neither but I am confident it is doable. We will need the amounts of the different transactions and the fees like mentioned.
Shielded transactions and their amount would be excluded from the final amount because there is no way to tell if they are still owned by the address or not (I think that was the point of it).
Actually, there might be no way around from getting the balance from the node directly since some balances cannot be calculated based on transactions. E.g. the reward balance continuously increases over time without an actual on-chain transaction. So I would rather prefer having an easy way to query the balance directly towards the node (or at least some of the balances). Here is a list of balances that I know of that are of interest:
Example of available balances for a cosmos chain: https://celestia.explorers.guru/account/celestia1uvytvhunccudw8fzaxvsrumec53nawyjqw83yr
Do Namada rewards follow the same mechanisms as cosmos chains? i.e. continuously (& silently) updating unclaimed rewards & commissions balances? My understanding is that Namada uses tendermint, but not cosmos SDK, and all the rewards functionality of networks such as celestia is provided by cosmos SDK not tendermint.
I think, even the concept of how balance state is kept, i.e. the idea of multiple types of balances like rewards & commissions, is part of cosmos SDK and thus, as far as I know, not used in Namada.
That said, I haven't yet studied how Namada handles rewards, so it's quite possible that it acts the same way, where rewards accrue without any transactions.
This indexer is no longer being maintained by request of heliax/namada team and it will be archived soon.
Reading the balance from the node is a hassle. Apparently the only way to do it is by making this call:
To retrieve the balance for tnam1qph60hh43apm3pvw6fk6cnzjaw5g2l3mrcdu9f9p this call must be made:
Response:
I have learned that the response.result.value must be deserialized with base64 with borsh into a request specific object (here it would an Amount object).
Ideally, this complexity is abstracted away and easily accessible through the indexer.
:link: zboto Link