Hot answers tagged

7

Try the below snippet: // @abi table tests i64 struct test_rec { test_hash hash; account_name creator; uint64_t primary_key() const { return hash; } account_name get_creator() const { return creator; } }; typedef eosio::multi_index<N(tests), test_rec > tests;


4

After looking through the example contracts, I finally found one that had an array of objects. To receive them, the contract needs to declare the parameter as a std::vector<uint128>. The multi_index table structure can store them by declaring the corresponding field in the structure in the same way. This is best shown by the identity contract's ...


2

To avoid leaving this question unanswered: OP solved their issue by increasing the max-transaction-time in their config file.


2

I'm not familiar with that specific error message, but what I do know is that the ABI generation feature will only work if your code is properly annotated by marking the actions and DB tables like shown in this example: https://github.com/andresberrios/token_ram_recovery/blob/master/token_ram_recovery.hpp There you can see that the action methods have been ...


2

The solution to my problem was that the wasm file had to exactly match the name of the contract in the attributes of the contract class. So as my file was called mycontract.wasm, I had to have the following in my contract class: class [[eosio::contract("mycontract")]] token : public contract { // the name of the class must be mycontract ... }; After this, ...


2

Your code should be like this // @abi action void token::create( account_name issuer, asset maximum_supply ) { require_auth( _self ); auto sym = maximum_supply.symbol; eosio_assert( sym.is_valid(), "invalid symbol name" ); eosio_assert( maximum_supply.is_valid(), "invalid supply"); eosio_assert( ...


1

You can fix this by starting nodeos while setting --abi-serializer-max-time-ms to 50000 or so. I'm not sure if there's such an option in eos-js but if you get the error using cleos, you can additionally start keosd while setting --http-max-response-time-ms= to 1000 or so.


1

I wasn't getting an abi file, but it was compiling fine. I finally noticed that I had the file named: widgets.cpp but the class was widget. Watch out for missing "S"s. Ran again and the abi file appeared.


1

Here is an excellent example of how to use binary extensions: https://github.com/EOSIO/eosio.cdt/blob/ab8002109adc4f39d17c7ac38c4d8582af74190a/docs/guides/binary-extension.md I will post the full text here for the case that the link gets taken down, and also it helps with SEO: eosio::binary_extension Let's fully explain what the eosio::...


1

There are currently no recommended tools for generating ABI automatically. However, there's an article in the documentation about how to write an ABI file yourself. From the article: As of v1.2.0, the eosio.wasmsdk was decoupled from the core repository. This change has introduced an eosiocpp regression where the legacy eosio-abigen is no longer ...


1

You can use type? for optionals, similar to type[] for arrays.


1

So I have been in discussion with Todd Fleming from B1, and he said that this is currently not possible. The solution is to include the other classes as members within the concrete class: class A { }; class B { }; class C { A foo; B bar; }; The enhancement to the ABI file will not be implemented unless there is a large demand for it. So if this is a ...


1

OK I found the answer in developers telegram. If anyone has the same problem you can use: vector<vector<foo>> and in the abi file you define a new type foo_vector of type foo[] and then on your table you define it as foo_vector[]


1

Perhaps when you were synching, at that moment in time, eosforumrcpp had an invalid ABI version? Right now, it seems like their versioning is fine: $ cleos get abi eosforumrcpp { "version": "eosio::abi/1.0", ... } This should pass the check in abi_serializer.cpp: EOS_ASSERT(starts_with(abi.version, "eosio::abi/1."), ...


1

The key_names is a list of the primary key and all the secondary keys. The key_types is the type of each of the respective keys. In a simple table (only a primary key), the type is always uint64 or name, and they key_name is an element from the struct referenced by the type variable.


1

Answering my own question, The bin data should be generated for each individual json in payload and appended in the actions field as a list. The transaction will then be signed, packed and pushed.


1

Macros should work, but you'd have to edit the eosiocpp script in order to be able to use them when you compile the code. You can't just do eosiocpp -DGEN_TABLE like in normal c++.


1

It isn't possible to call a non-ABI action in the way you want. Only something in the ABI can be called in a transaction, whether it is deferred or not.


1

The eosiocpp compiler was the old deprecated way of compiling the c++ into wasm contracts. The new way uses a compiler called eosio-cpp, which is very confusing. With eosio.cdt, you can generate a CMake build system using eosio-init, and it will generate the cmake command target_ricardian_directory, where you should specify your ricardian contract files. ...


1

check your ABI using: cleos get abi YOUR_CONTRACT If returned ABI is null update your contract: cd YOUR_CONTRACT_DIR cleos set contract YOUR_CONTRACT_ACC . YOUR_CONTRACT.wast YOUR_CONTRACT.abi -p manantest I hope it will help you


1

The ABI file is actually generated from the cpp file you're compiling from. eosiocpp -g file.abi file.cpp This is also the reason you use the macro in your code to tell the compiler which of your functions is an action and which of your tables are callable. EOSIO_ABI( scope, (action 1)(action 2)...(action n) ); From here, the ricardian contract can be ...


1

This depends on which version of EOSIO you are using. If you are using v1.3 or higher, then you should change compilers to use eosio.cdt, not eosiocpp. There are many differences between the two, including that an account name now has a dedicated class called name, whereas earlier versions just used a uint64_t. Other changes include removing the concept of ...


1

You can create your custom struct in code and add EOSIO_SERIALIZE to it. After, you can use it in your contract action parameters like this: void funcname(const account_name account, st_data_req request); Then when you push your action, you may use JSON just like in this example: '["acctname", {"structval1": 12.123123,"structval2": 29.123123}]' Answering ...


1

The functionality of the system contracts are built in and can't be changed unless there is consensus amongst the BPs. However, for your own contract you can create actions and the serializer will figure out what arguments it should take. For example: \\\@abi action void mycontract::test(int x, string y); EOSIO_ABI( eosio::mycontract, (test) ) or with ...


Only top voted, non community-wiki answers of a minimum length are eligible