0

Let's say I have deployed the standard eosio.token contract to an account called "myeosiotoken," and I have used it to create an "ABC" token. Then, I issue 1,000 ABC to "someaccount1" and 2,000 ABC to "someaccount2."

I can retrieve the balance of 1,000 ABC on someaccount1 with:

cleos get table myeosiotoken someaccount1 accounts

And I can retrieve the balance of 2,000 ABC on someaccount2 with:

cleos get table myeosiotoken someaccount2 accounts

Is there a way to use cleos to retrieve a list of ALL balances of token ABC in the accounts table?

Is there a way to use cleos to retrieve a list of ALL balances of ALL tokens in the accounts table?

New contributor
Fabiana Cecin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Just use cleos get table myeosiotoken myeosiotoken accounts to retrieve balance. – Mr.Y Feb 11 at 13:14
  • Unfortunately, that will only retrieve the token balance held by the contract itself. – Fabiana Cecin Feb 11 at 13:16
  • yes that you exactly asked in first question. – Mr.Y Feb 11 at 13:19
  • My bad, that's poor wording on my part. Fixing it. – Fabiana Cecin Feb 11 at 13:20
  • no problem..... – Mr.Y Feb 11 at 13:22
0

The only way to do it with a standard eosio.token contract would be to use something like the state_history_plugin to see which accounts had the open command used on them, and then write a script to loop through all of those accounts with the get table command you state in the question.

If you are capable of adapting the contract for yourself, then you can always add another table which would list all of the users and their current balances.

You can also check all scopes with: cleos get scope -t accounts myeosiotoken

  • I just found out about "cleos get scope -t accounts myeosiotoken", it lists all "scopes" (which seems to mean blockchain accounts, in my mind) that "have" records in the given table (in that case, "accounts"). If you omit the -t parameter, it lists all accounts that "have" (whatever that means in the memory model) any table records that "originate" (again, whatever) from the given contract/account (myeosiotoken in this case). It won't list the token balances, but it seems to give the full list of accounts that have a table row/balance that I can query. – Fabiana Cecin Feb 11 at 14:56
  • Thanks I didn't know that! I added it to the answer – Phillip Hamnett - EOS42 Feb 11 at 16:15

Your Answer

Fabiana Cecin is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.