Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
Bumped by Community user
Bumped by Community user
Source Link

Execute get_supply function within contract

I want to execute get_supply from currency.hpp.

Here is the definition:

asset get_supply( symbol_name symbol )const {
        accounts t( _contract, symbol );
        return t.get(symbol).balance;
     }

Currency constructor:

currency( account_name contract )
         :_contract(contract)
         { }

I am trying like that:

void get_supply(extended_asset mytoken) {
        extended_symbol es = mytoken.get_extended_symbol();
        auto sym = es.symbol;
        auto curr = currency(N(mytoken.token));
        auto stats = curr.get_supply(sym);
    }

mytoken.token -> custom token contract (copy of eosio.token)

I am getting error:

Error 3050003: eosio_assert_message assertion failure Error Details: assertion failure with message: unable to find key

Anyone knows how to use this function correctly?