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?
1 Answer
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));
eosio.token
as we did while we get the account balance inside contract. Now you have to call the table action using eosjs.