I have copy the account
struct from the smart contract eosio.token
into my own contract and typedef multi_index like this:
//@abi table accounts i64
struct account
{
asset balance;
uint64_t primary_key() const { return balance.symbol.name(); }
};
typedef eosio::multi_index<N(accounts), account> accounts;
And I define a accounts
type variable named accountstable
which code is N(eosio.token)
and scope is _self
. Code is here:
accounts accountstable(N(eosio.token), _self);
const auto &ac = accountstable.get(CORE_SYMBOL);
return ac.balance;
But this doesn't work for me and get the error message means can not find the key. Something wrong?