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

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));

Your Answer

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.