4

In the new version of eosjs, the getCurrencyBalance() method is no longer supported. How can I still get the currency balance of an account using eosjs?

  • I think now you have to get the currency table of eosio.token as we did while we get the account balance inside contract. Now you have to call the table action using eosjs. – Nirdesh Kumar Choudhary Oct 17 '18 at 5:22
1

In eosjs v20.x, getCurrencyBalance has been renamed to get_currency_balance, and moved within the Rpc object.

You can use it like this...

const fetch = require('node-fetch');
const { JsonRpc } = require('eosjs');

// Instantiate a new JsonRpc object, with the Network Api Uri, and a request object
const rpc = new JsonRpc('https://api.kylin.alohaeos.com', { fetch });
// Request the balance, passing in the token contract, the account name, and the token symbol
rpc.get_currency_balance('eosio.token', 'eospaceioeos', 'EOS').then((balance) => console.log(balance));
  • it would be great to see an updated version of this answer – botbot Mar 20 at 10:51
  • error jsonrpc not a constructor – botbot Mar 22 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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