How to get the list of owners for any asset?

+1 vote
I issued an asset which is now distributed across many users in multiple nodes. Is there any way to get the list of owners for the asset? I need this in my PHP application. So even if there are libraries that offers this kind of functionality, it's ok.
asked Feb 13, 2017 by Cypher

1 Answer

+1 vote
 
Best answer

MultiChain does not currently have an API for this. You have a few possible workarounds:

  • subscribe to an asset and then retrieve all transactions relating to it in a single API call to listassettransactions. From that you could reproduce the current balances of all users, by summing up all the individual balance changes made by each transaction.
  • Use importaddress to start tracking each address of interest (you can provide many addresses in a single call) then getmultibalances to retrieve the balance for all addresses for one specific asset.
  • Wrap something around the MultiChain Explorer which does keep track of this information: https://github.com/MultiChain/multichain-explorer
answered Feb 14, 2017 by MultiChain
selected Apr 6, 2017 by Cypher
Thank you. I already thought of doing these. But I'm just concerned that "subscribe" and "importaddress" with rescan=true (which would be necessary) might impact the application's performance. So I integrated the multichain-explorer with my application just for display only purpose. But for processing this info, explorer might not help. Any suggestion?
You can do the rescan only one time, on the last call, and it will rescan for all relevant addresses or assets. Also, when you subscribe to an asset, it only scans the blockchain from the block in which the asset was issued. Finally, you can use the autosubscribe runtime parameter to automatically subscribe to new assets as they are created.
Whats the problem if we directly use getmultibalances command like "getmultibalances * assetid" . The above command also  gives the list of owners for the given assetid. Instead of using subscribe,listassettransactions,importaddress, we can directly use getmultibalnces command. If there any issues in directly using above command, please let me know.
getmultibalances only returns balances for addresses being tracked by the node, not for all addresses in the blockchain.
...