2

I'm following the https://developers.eos.io/eosio-home/docs/token-contract block one tutorial using the latest eosio/eos-dev docker image (v1.4.0).

I have some issues when I compile eosio.token.cpp using eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp, here are the errors:

root@ac461d2b1fa1:/opt/contracts/eosio.contracts/eosio.token# eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp

In file included from src/eosio.token.cpp:6:
include/eosio.token/eosio.token.hpp:20:12: warning: unknown attribute 'contract' ignored [-Wunknown-attributes]
   class [[eosio::contract("eosio.token")]] token : public contract {
           ^
include/eosio.token/eosio.token.hpp:41:39: error: unknown type name 'symbol'
         void open( name owner, const symbol& symbol, name ram_payer );
                                      ^
include/eosio.token/eosio.token.hpp:44:40: error: unknown type name 'symbol'
         void close( name owner, const symbol& symbol );
                                       ^
include/eosio.token/eosio.token.hpp:46:64: error: unknown type name 'symbol_code'
         static asset get_supply( name token_contract_account, symbol_code sym_code )
                                                               ^
include/eosio.token/eosio.token.hpp:53:77: error: unknown type name 'symbol_code'
         static asset get_balance( name token_contract_account, name owner, symbol_code sym_code )
                                                                            ^
include/eosio.token/eosio.token.hpp:64:65: error: no member named 'code' in 'eosio::symbol_type'
            uint64_t primary_key()const { return balance.symbol.code().raw(); }
                                                 ~~~~~~~~~~~~~~ ^
include/eosio.token/eosio.token.hpp:72:64: error: no member named 'code' in 'eosio::symbol_type'
            uint64_t primary_key()const { return supply.symbol.code().raw(); }
                                                 ~~~~~~~~~~~~~ ^
src/eosio.token.cpp:20:34: error: no member named 'code' in 'eosio::symbol_type'
    stats statstable( _self, sym.code().raw() );
                             ~~~ ^
src/eosio.token.cpp:21:42: error: no member named 'code' in 'eosio::symbol_type'
    auto existing = statstable.find( sym.code().raw() );
                                     ~~~ ^
src/eosio.token.cpp:38:34: error: no member named 'code' in 'eosio::symbol_type'
    stats statstable( _self, sym.code().raw() );
                             ~~~ ^
src/eosio.token.cpp:39:42: error: no member named 'code' in 'eosio::symbol_type'
    auto existing = statstable.find( sym.code().raw() );
                                     ~~~ ^
src/eosio.token.cpp:50:28: error: use of undeclared identifier 'same_payer'
    statstable.modify( st, same_payer, [&]( auto& s ) {
                           ^
src/eosio.token.cpp:69:34: error: no member named 'code' in 'eosio::symbol_type'
    stats statstable( _self, sym.code().raw() );
                             ~~~ ^
src/eosio.token.cpp:70:42: error: no member named 'code' in 'eosio::symbol_type'
    auto existing = statstable.find( sym.code().raw() );
                                     ~~~ ^
src/eosio.token.cpp:80:28: error: use of undeclared identifier 'same_payer'
    statstable.modify( st, same_payer, [&]( auto& s ) {
                           ^
src/eosio.token.cpp:95:32: error: no member named 'code' in 'eosio::symbol_type'
    auto sym = quantity.symbol.code();
               ~~~~~~~~~~~~~~~ ^
src/eosio.token.cpp:116:52: error: no member named 'code' in 'eosio::symbol_type'
   const auto& from = from_acnts.get( value.symbol.code().raw(), "no balance object found" );
                                      ~~~~~~~~~~~~ ^
src/eosio.token.cpp:127:42: error: no member named 'code' in 'eosio::symbol_type'
   auto to = to_acnts.find( value.symbol.code().raw() );
                            ~~~~~~~~~~~~ ^
src/eosio.token.cpp:133:28: error: use of undeclared identifier 'same_payer'; did you mean 'ram_payer'?
      to_acnts.modify( to, same_payer, [&]( auto& a ) {
                           ^~~~~~~~~~
                           ram_payer
src/eosio.token.cpp:124:56: note: 'ram_payer' declared here
void token::add_balance( name owner, asset value, name ram_payer )
                                                       ^
src/eosio.token.cpp:139:37: error: unknown type name 'symbol'
void token::open( name owner, const symbol& symbol, name ram_payer )
                                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.

Any idea ?

  • Update: after installing the latest update (v1.3.2) of eosio.cdt, the compilation worked fine. – mounibec Oct 18 '18 at 7:57
  • please consider adding it as an answer if it solves the question – confused00 Oct 18 '18 at 10:18
  • Update: There was an issue on the 1.2.1 tag, so just make sure you clone the code again using the 1.2.1 tag. – mounibec Oct 20 '18 at 20:39
2

Well, what I learnt from EOS developers Telegram group:

  1. Update eosio.cdt. The latest version is 1.3.2
  2. Also, although the tutorial says not to use abigen since abi is included...we need to use abigen since eosio.token.abi is not included in the download. So the command need to be changed as below:

    eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen
    

Also, Deploy token command looks for abi file in "eosio.token/abi/eosio.token.abi" while the command above generates the abi file in eosio.token folder. So the path needs to be fixed in "cleos set contract" command.

Hope this helps!

1

You need to download the hpp & cpp files:

$ wget https://raw.githubusercontent.com/EOSIO/eosio.contracts/master/eosio.token/include/eosio.token/eosio.token.hpp
$ wget https://raw.githubusercontent.com/EOSIO/eosio.contracts/master/eosio.token/src/eosio.token.cpp

Next, change import statement:

$ vim eosio.token.cpp

change line 6: include "eosio.token.hpp"

Now you can compile wasm:

$ eosio-cpp -o eosio.token.wasm eosio.token.cpp --abigen

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.