I am trying to get user tokens with the following method:

static async getUserTokens(userAccount) {
    console.log("Get tokens for: " + userAccount);
    try {
      const rpc = new JsonRpc("", { fetch });
      const resp = await rpc.get_currency_balance({
        code: "electro.coin",
        account: "bob",
        symbol: "EL"
      return resp.rows[0];
    } catch (err) {

and it returns:

eosjs-jsonrpc.js:99 POST 500 (Internal Server Error)
Error: Invalid cast from type 'object_type' to string
    at new RpcError (eosjs-rpcerror.js:23)
    at JsonRpc.eval (eosjs-jsonrpc.js:118)
    at step (eosjs-jsonrpc.js:36)
    at Object.eval [as next] (eosjs-jsonrpc.js:17)
    at fulfilled (eosjs-jsonrpc.js:8)

Any explanation what am I missing? The token contract is electro.coin, the user is bob and the symbol is EL. I hard-coded the elements for better debugging, but no luck so far...

  • 1
    Have you tried converting the object to a string to satisfy the error message? JSON.stringify(data) Jul 26 '19 at 1:47
  • It appears that my whole data was added to the scope field and the other fields stayed as undefined. Thank you @PhillipHamnett for the hint, now I am using: const resp = await rpc.get_currency_balance("electro.coin", userAccount, "EL"); and it works :) Jul 26 '19 at 21:54

Your Answer

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

Browse other questions tagged or ask your own question.