If I am using eosio.token as my token contract (or I know my token contract during compile time), the following code will work.
accounts accountstable(N(eosio.token), account);
auto itr_a = accountstable.begin();
eosio::print (itr_a->balance);
However, I want to store the token contract account as a configuration within the contract. It looks like this:
struct config
{
account_name token_contract;
account_name primary_key() const { return token_contract; }
EOSLIB_SERIALIZE(config, (token_contract));
};
typedef eosio::multi_index<N(configs), config> config_table;
When I replace the name of the token contract from the hard-coded token name in the initial example, it doesn't provide the correct information. It provides some random long integer that I think is from the wrong memory location.
accounts accountstable(N(itr->token_contract), account);
auto itr_a = accountstable.begin();
eosio::print (itr_a->balance);
How can I store the token contract name (and the symbol for that matter) dynamically in a config multi_index within the smart contract so that I can check the balance and perform transfers?
extended_symbol
type?