8

Until eosio.cdt v1.6 You could use: eosio::current_time() now() From eosio.cdt v1.6 onwards You have to #include <eosio/system.hpp> and then you can use: eosio::current_time_point eosio::current_block_time


4

Figured it out. In case anyone else has this issue. Looks like the index name can't have an underscore in it. Changed to: typedef multi_index<"settings"_n, setting, indexed_by<"settingkey"_n, const_mem_fun<setting, uint64_t, &setting::by_setting_key>> > setting_index;


3

Problem solved ! I didn't go through the CHANGELOG for the latest 1.2 to 1.3 upgrade. It turns out, the EOSIO_ABI macro has been renamed EOSIO_DISPATCH and so, it seems there is no problem with compilation on my machine. One thing is remaining, but is linked to ABI generation, for which I took the decision to write it manually.


3

the problem is that the primary key index cannot be 128 bits long. it must be 64 bits. but other indexes can be 128 bits so my solution was to implement an auto-generated monotonic primary key and then define the index I wanted as a secondary index struct [[eosio::table]] _prices { uint64_t id; symbol base; symbol quote; ... ...


3

I had the same question and ended up figuring it out by reading the multi_index.hpp from eosio.cdt code and wanted to share my solution. Instead of using auto, declare the type by using myindex::const_iterator: struct [[eosio::table]] _obj { name key; uint64_t primary_key() const { return key.value; } }; typedef eosio::multi_index<name("...


2

You can call name.value to get a uin64_t representation of the name. In your find call, you want to do auto iterator = host_games.find(host.value); to match the uint64_t type that your secondary index is returning.


2

For uninstalling current eosio.cdt go to usr/local there you find eosio.cdt folder just delete that folder and again install your required version.


2

The cleos version client does returned the version. However, it is the build version. To translate into human readable version, you can check https://github.com/EOSIO/eos/tags and search for the build version. Then you can find the version as v1.4.4. The 59626f1e you got is the first 8 digit hash of the last git commit used to build cleos. Which can be ...


2

With eosiocpp everything works fine because types.hpp is defined in the directory ...\eos\contracts\eosiolib. In eosio.cdt in ...\eosio.cdt\libraries\eosiolib there is only types.h and not types.hpp and so types.hpp cannot be found.


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

You need to include eosio.hpp before the other includes. #include <eosio/eosio.hpp> Sidenote: this actually seems to be a problem with cdt 1.6.1 and will hopefully be fixed with next releases Issue#532


2

If you don't care about the data from old_table: Erase all records from old_table Deploy NEWCONTRACT with modified old_table If you want to persist the data from old_table: Define the new and old structs/tables in NEW_CONTRACT1 Write a function that will move data from old_table to new_table; adding new column Deploy NEW_CONTRACT2 version that has ...


2

If you use a custom type you must also define the type to a built in type. A list of accepted types by EOSIO can be found here, https://eosio.stackexchange.com/a/1932/3333. For instance, your custom enum is actually a uint8_t type. You'll need something like .. ## header file enum e_vote_option { upvote = 0, downvote } typedef uint8_t vote_option; ...


1

solved and it was because of the virtual machine. https://github.com/EOSIO/eosio.cdt/issues/123


1

To anyone having the same issues. I managed to fix it like this: struct [[eosio::table]] game { uint64_t id; //auto increment name host; name guest= name("none"); name player_to_play =name("none"); name winner = name("none"); string2dvector game_state; string game_name; uint64_t primary_key() const { return id; } uint64_t ...


1

You need to convert the uuid to a uint128_t and also store it as uint128_t to make it indexable so that you can use it as key. You can find more info about uuids and how they can be converted here. The following should work string uuid = "16cadf15-dda7-4be2-8026-c3c7875322d"; std::replace( uuid.begin(), uuid.end(), '-', ''); // remove all '-' uuid = "Ox"+...


1

The problem you are describing definitely appears to be related to your VM only having one core. Please double check that your VM has 2 or more cores allocated to it, and that you have restarted your VM after making the necessary adjustment. Additionally, eosio.cdt 1.6.0 has some issues that may cause problems, please upgrade to eosio.cdt 1.6.1 immediately.


1

Everytime you update the ABI file, a record is stored on chain. The action is eosio::setabi. Therefore it would be possible to say which version of the ABI file was current on the blockchain at the time of a transaction being signed.


1

Is this CPU-billing-scheme still in use? To the best of my knowledge, yes Points 2. and 3. My understanding of CPU billing works is as follows: A BP receives your transaction, starts a timer, processes it as fast as they can, stops a timer. The time they record is the CPU billing time that you get charged. Therefore, the number of wasm instructions ...


1

Turns out there's one vital piece when using on_notify, the action being monitored must call require_recipient(<your contract account name with on_notify>). This sends a copy of the action to that account.


1

Some points: As mentioned in the other post myContract should be lowercase mycontract. The eosio::contract constructor changed since eosio.cdt 1.3. It takes 3 arguments now: mycontract(eosio::name receiver, eosio::name code, eosio::datastream<const char *> ds) : contract(receiver, code, ds) {}. Not sure if your mycontract already implements this as I ...


1

One issue is that your secondary index is called "by_expiration" which is not a valid eosio::name. It needs the same restrictions as any other name on EOSIO. Max 12 (actually 13) characters a-z0-5. Another one is that your class constructor is still the old one. It has changed since eosio.cdt 1.3. You're also not initializing the superclass eosio::contract ...


1

There are huge differences between the old eosio-cpp, the first versions of the cdt and the actual one. You don't have to initialize the table like you do while the constructor is called. You also need to use the Abi-Generator-Attributes instead of multi-index-typedefs. Take a look here: Abi-Generator-Attributes And here: Basic Usage


1

I guess this is not directly related to EOS.IO, but you get the compile error because you are using a single quote to divide your uint. This character is reserved for declaring chars. Here is a StackOverflow explanation to this: Single quotes vs. double quotes in C or C++ Just remove the ' from your definitions and it will hopefully work. const static ...


1

I have solved the issue by using below commands sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.9 sudo apt-get install --only-upgrade libstdc++6


1

It isn't possible to use future in smart contracts, because the whole thing is single-thread C++. Multithreading isn't supported and wouldn't work within the contract because it would potentially make the results of any code non-deterministic


1

When you are lost with EOSIO native types, you can look it up at eosio.cdt's eosiolib library (github) A explicit constructor is defined as following inside symbol.hpp constexpr explicit symbol_code( std::string_view str ) :value(0) { if( str.size() > 7 ) { eosio::check( false, "string is too long to be a valid ...


1

The contracts we should use come from the eosio.contracts git repo, not the ones in the eos repo. eosio.contracts repo: https://github.com/EOSIO/eosio.contracts This has to be compiled using the eosio.cdt repo eosio.cdt repo: https://github.com/EOSIO/eosio.cdt


1

The updated contract you're looking for is here. It uses the new name: https://github.com/EOSIO/eosio.contracts/blob/master/eosio.token/src/eosio.token.cpp


1

Not only changing EOSIO_ABI macro to EOSIO_DISPATCH, there are some more to be changed. account_name is removed. Use eosio::name. Constructor requires three parameters, receiver, code and ds. multi_index table needs integer as second parameter instead of name. Use [[eosio::xxx]] attribute instead of /// @abi N() macro is removed. Use "blahblah"_n operator ...


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