struct bal_detail {
uint64_t id;
account_name user_account;
account_name com_account;
uint128_t balance;
uint128_t frozen_balance;
bool is_fronzen;
auto primary_key()const { return id; }
account_name get_user_name()const { return user_account; }
EOSLIB_SERIALIZE( bal_detail, (id)(user_account)(com_account)(balance)(frozen_balance)(is_fronzen) )
};
typedef eosio::multi_index<N(bal_detail), bal_detail, indexed_by<N(by_user_name), const_mem_fun<bal_detail, account_name, &bal_detail::get_user_name> > > balance_detail_index;
public:
uint_128_t get_balance( const account_name account )
{
......
return balance;
}
I tried to define a method with a return value of uint128_t in the public of the class but failed. If there is no way to define a method with a return value, how can I query the custom structure data?
You just can't. Return values are not allowed in contract actions.
If you need to query data on other contracts, use the multi_index or singleton construct instead, with the code parameter set to the target contract instead of _self. Then, query the table like you would with your own tables.
@xJonathanLEI thanks
In this case, can the scope and code of multi_index be set to owner? It is the _self of the deployment contract because I don't seem to have different code requirements.
This is the current design. You can put the resulting information into the multi_index table if you really need it.
Most helpful comment
You just can't. Return values are not allowed in contract actions.
If you need to query data on other contracts, use the
multi_indexorsingletonconstruct instead, with thecodeparameter set to the target contract instead of_self. Then, query the table like you would with your own tables.