3

I have created smart contract inside the /build/contracts and running this comman generates empty abi file.

eosiocpp -g eosio.test.abi eosio.test.cpp

tried both hpp and cpp but same result.

  • Can you confirm your passing these actions into EOSIO_ABI? Add the code to the question as well perhaps. – John Williamson Jun 25 '18 at 3:42
  • try to add @abi table or action to your table or function header – Jimmy Guo Jun 25 '18 at 14:44
  • Actually the code is based on eosio.token, I'm trying to play around with it. EOSIO_ABI( eosio::test, (create)(issue)(transfer)(hi) ) – Dominic Jun 26 '18 at 1:18
  • There are lots of developers experiencing this issue, I wonder why and what is the common cause of this issue? – Dominic Jun 26 '18 at 1:19
  • I don't think annotations are still necessary if you are using the EOSIO_ABI right? – Dominic Jun 26 '18 at 1:23
2

When you're generating your ABI consider a few things:

  1. Use the new command eosio-cpp

    For example: eosio-cpp -I include -o my_contract.wasm my_contract.cpp -abigen

  2. Use the C++ 11 attributes included in the newest EOSIO version such as [[eosio::action]], [[eosio::table]], [[eosio::contract]]

  3. If the contract structure is too complicated at this point "abigen" could fail to generate the ABI file. You should create it manually or eventually fix broken parts. Take a look at Understanding ABI Files :)
1

you need extra comments marked in hpp file to help eosiocpp generate concrete abi file. for actions, you need to add comment

c++ //@abi action

above its declaration. for multi_index table, you need to add comment

c++ //@abi table <underlying class or struct name> (i64|i32)

above the underlying class or struct definition.

  • what is the difference of i64 and i32? The primary key only receive uint64, right? – Jimmy Guo Jul 27 '18 at 11:39
1

You could use of the newest macros:

Added ACTION macro which is simply a shortcut for [[eosio::action]] void.
Added TABLE macro which is simply a shortcut for struct [[eosio::table]].
Added CONTRACT macro which is simply a shortcut for class [[eosio::contract]].

1

I'm assuming you are using one of the new CDTs

In my case the following command worked

eosio-abigen hello.cpp --contract=hello --output=hello.abi
0

I had this happen to me last night. Make sure the class name and your file names match.

In other words, if you're compiling the hello contract, make sure the file names are hello.hpp and hello.cpp.

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.