Go: Horizon api find all trustees to an asset issuing account

Created on 12 May 2018  路  10Comments  路  Source: stellar/go

I would like a feature to be able to find all accounts that trust an issuing account through the horizon api.

horizon

Most helpful comment

We have another important request for this feature (get trustees + balances for asset). @bartekn what are your thoughts on how to put this together in an efficient way?

I'd imagine an interface with an endpoint like this:
/assets/balances?asset_code=X&asset_issuer=Y

It'd also have the standard cursor, limit, and order fields.

The return value would be a list of account, balance pairs for all accounts holding that asset.

All 10 comments

@bartekn: My team also need this need a feature where we can query all trust lines created for the asset issued along with its balances.

We have another important request for this feature (get trustees + balances for asset). @bartekn what are your thoughts on how to put this together in an efficient way?

I'd imagine an interface with an endpoint like this:
/assets/balances?asset_code=X&asset_issuer=Y

It'd also have the standard cursor, limit, and order fields.

The return value would be a list of account, balance pairs for all accounts holding that asset.

This feature is hard to implement in horizon's current form.
Horizon reaches out to core's db for trustlines, but core does not have an index on trustlines by assets.

This comes back to a necessity to have horizon maintain it's own view on the ledger entries it's interested in tracking.

Hello @tomquisel , we would like to have this feature as well. Our application needs to get the token (asset) distribution (the amount held by each wallet that holds tokens), so this endpoint would be very useful!

@IlyaShkapo thanks for highlighting this. We need to solve a larger architectural issue with Horizon before we take on this issue. We should be able to resolve this issue in the second half of 2019. Until then, hopefully you can find a work-around.

One possible approach would be for you to write a script that connects directly to your Stellar core's database and makes the appropriate (un-indexed) request against the trustlines table. It should be manageable since it's not a huge table, and I assume it's something you only need to run periodically.

Stellar.expert's API supports this. For example: https://api.stellar.expert/api/explorer/public/asset/HKDT-GABSZVZBYEO5F4V5LZKV7GR4SAJ5IKJGGOF43BIN42FNDUG7QPH6IMRQ/holders

However, (a) I don't know if there's any SLA attached to it and (b) it ingests from history archives so information can be up to 5 minutes stale. (@orbitlens)

However, (a) I don't know if there's any SLA attached to it

That's strictly speaking is not a public API endpoint yet. Thus there is no SLA, the data format may (and will) be changed without preliminary notice. @IlyaShkapo drop me a message with details of your case, and we'll discuss it.

(b) it ingests from history archives so information can be up to 5 minutes stale.

I found a way to overcome this limitation; the aggregated data will be available immediately once the ledger is closed. Currently working on the implementation, expect it to be ready by the end of April.

Thank you @tomquisel , @tomerweller for the answer!

We've already used this workaround for a while, but we faced several issues like interference between SQL users when they exceed connections in the pool. So, as for now, we have to deal with it for a time being, but we expect that this functionality will be available from Horizon API to remove a the dependency on the database and easily switch between nodes.

@orbitlens, we use this token distribution functionality to provide a possibility for the issuer to see and manage token holders. Could you be so kind as to drop me a message when you'll release the final version of Stellar Experts API for our consideration?

Thank you in advance!

Make sure we have #1550 and better staging environment before we ship this. We will probably display trust line balances and this is a critical information for some apps.

Closed in #1835.

Was this page helpful?
0 / 5 - 0 ratings