EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 463 forks source link

eos.getCurrencyBalance() returns "Fail to retrieve account for [code]" #65

Closed brangnu closed 6 years ago

brangnu commented 6 years ago

I am trying to get the current balance of an account that is generated from the docker image provided in the repo.

I called the method getCurrencyBalance() which expects the following properties.

"get_currency_balance": {
    "params": {
      "code": "name",
      "account": "name",
      "symbol": "optional<string>"
    },
    "results": "asset[]"
  }

I am wondering what the "code" parameter is for. It seems like I am getting the error from there. What specifically is a "code" for an account? I have accounts name generated by the docker image. I tried to insert "eos", "cur", "eosio.token" for the accounts. But I get The following error only:

{"code":500,"message":"Internal Service Error","error":{"code":3010002,"name":"account_query_exception","what":"Account Query Exception","details":[{"message":"Fail to retrieve account for eos","file":"chain_plugin.cpp","line_number":302,"method":"get_abi"}]}}

So how can I find the correct code for an account?

chris-allnutt commented 6 years ago

Unless you created an account named eos or cur there won't be an account with those names. You need to create the accounts. The only default account is eosio.

brangnu commented 6 years ago

@chris-allnutt I have tried with that default account(eosio) you mentioned too, but getting a different error now. {"message":"Table accounts is not specified in the ABI"}

What is the default code for the default account "eosio"? How can I find it?

chris-allnutt commented 6 years ago

This may be an issue with the contract deployed in dawn3. If you are able to you may want to try testing against the latest alpha release with eosjs 9. If that doesn't work i can try a few things on my end.

jcalfee commented 6 years ago

There are examples in docker/up.sh

brangnu commented 6 years ago

@chris-allnutt I am on eosjs 9.0.1 version. So, I think it is the lastest version. Could you clone the repo, run the docker and try to get balance of an account to see if you get the same error? Thanks for your help though!

brangnu commented 6 years ago

@jcalfee Hi,

@chris-allnutt mentioned earlier that there is a default account name "eosio". How can I retrieve the balance of that account? What is the code for that account?

jcalfee commented 6 years ago

This is the default account named eosio as it appears in up.sh.. As far as I know this is how it will be deployed automatically later. Right now we need to re-deploy it to get everything working correctly.

# Hack: publish main eosio smart contract
cleos set contract eosio contracts/eosio.system -p eosio@active

Both get_currency_balance and get_currency_stats do not work for eosio .. The errors are due to a missing table. This contract is being converted from native to virtual (a true smart contract). This basically means the conversion is not finished yet.