Find quantity of specific asset inside the wallet

+2 votes


I have created two assets inside my wallet:

1. AssetZ

2. Asset1

Using command  "multichain-cli chain6 getaddressbalances 1E59W7MfTaJ5EYbzqWoPTwHJGUZTWWvEaYfMKt"

I get details about both the assets present inside this address, as shown below:

        "name" : "AssetZ",
        "assetref" : "17588-266-60025",
        "qty" : 1000.00000000
        "name" : "asset1",
        "assetref" : "91-265-21387",
        "qty" : 100.00000000



But what command should I run, if I want to find the quantity of only AssetZ inside the wallet?



asked Feb 8, 2016 by anuj

2 Answers

+1 vote

I'm afraid there is no direct API for this. You need to extract the quantity you want from the response to getaddressbalances, by traversing the JSON response.

answered Feb 8, 2016 by MultiChain
Also would like to know is multichain working on to create such an API?
Does multichain look at the questions being asked and update its API accordingly, or we can send API upgradation request to some other forum/url?
Yes, we design our future API enhancements based on the questions we receive. However in this case there's a pretty good solution using the current API, so I don't think that adding a new per-address per-asset API will be a high priority. (Unless, that is, we receive a lot of similar questions and requests.)
ofcourse. But I was thinking about following use case:

Suppose there is a Factor (say a bank). It get's into lacks of contracts (different consumers/producers). And let's have a unique asset for each contract.
Now if we want to see the assets for this Factor for a particular contract, we will have to fetch all the records (as in current scenario, we are getting JSON array). From this JSON array we will need to extract the required JSON object.

If there will be an API which accepts say for example, asset name and returns all details of that asset, then such high computation won't be required at client.
+1 vote

Yes you can I've done this. look at the getmultibalances command. accepts a row of addresses and the asset name. 

getMultiBalances({ addresses: addresses, assets: ["asset-name"] })
answered Jul 18, 2016 by gravyplaya