9
votes
Accepted
How to get current time in different versions of EOSIO
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::...
5
votes
Accepted
How do I pass an iterator?
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::...
5
votes
Accepted
Returning values from actions
Can you call the below to activate ACTION_RETURN_VALUE
cleos push action eosio activate '["c3a6138c5061cf291310887c0b5c71fcaffeab90d5deb50d3b9e687cead45071"]'
It looks like you called ...
4
votes
Accepted
eosio.cdt 1.3.2 indexed_by error: non-type template argument is not a constant expression
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<"...
4
votes
Accepted
How to create composite primary key?
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 ...
3
votes
Accepted
EOSIO_ABI macro problem on MacOS, can't use for contract implementations
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 ...
3
votes
How to upgrade a multi_index table in a smart contract
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 ...
3
votes
Accepted
Store enum value in table
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 ...
3
votes
Accepted
How to pass specific eosio-cpp/eosio-ld options via cmake
cmake will compile source files into object files first and link them by linker, so you need to add -stack-size option to linker option. (When you run eosio-cpp in command-line, passing -stack-size to ...
3
votes
Accepted
Set source file properties called with incorrect number of arguments
It seems you use eosio.cdt v1.8.0-rc1.
macro (target_ricardian_directory TARGET DIR)
target_compile_options( ${TARGET} PUBLIC -R${DIR} )
file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses....
2
votes
Multi_index query with new CDT
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 =...
2
votes
Multi_index query with new CDT
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 ...
2
votes
Accepted
How to uninstall CDT and reinstall?
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
votes
Accepted
How can I tell what version I am running with cleos version client?
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 ...
2
votes
Accepted
How to solve fatal error: 'eosiolib/types.hpp' file not found #include <eosiolib/types.hpp>?
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 ...
2
votes
Why does the -abigen option in eosio.cdt not work?
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 ...
2
votes
Accepted
How do you define uuid indexes in contract tables?
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.
...
2
votes
ABI file not generated
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 ...
2
votes
no member named 'check' in namespace 'eosio'
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 ...
2
votes
What is the difference between std::string and eosio::string?
According to the release notes:
A new type to act as a more efficient replacement to std::string has
been added (#459). eosio::string should be more efficient in memory
usage and help to reduce ...
2
votes
Set source file properties called with incorrect number of arguments
When both xx.contracts.md and xx.clauses.md are present, ${contracts} is a ;-list, which must be quoted. This edited macro defn works for me without complaint in v1.8.1 (using CMake 3.10.2 on Ubuntu ...
1
vote
eosio-cpp -abigen hello.cpp -o hello.wasm
solved and it was because of the virtual machine.
https://github.com/EOSIO/eosio.cdt/issues/123
1
vote
Accepted
Serialization Error Processing WASM while following hello.cpp tutorial
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 ...
1
vote
Accepted
Ricardian Contract
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 ...
1
vote
CPU-Usage Optimization
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, ...
1
vote
Accepted
on_notify not being fired on local or jungle testnet
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 ...
1
vote
Custom dispatcher new CDT
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 ...
1
vote
Multi_index issues
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.
...
1
vote
Multi_index issues
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 ...
1
vote
How to compile uint with single quotes?
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 ...

tmm♦
- 2,114
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
eosio.cdt × 92smart-contract × 39
eosio-code × 14
eosio-cpp × 14
nodeos × 8
multi-index × 8
eosio.system × 8
cleos × 7
eosjs × 7
eosio.token × 7
eosiocpp × 7
compilation × 7
c++ × 6
contract-development × 4
accounts × 2
action × 2
dapp × 2
deferred-transactions × 2
abi × 2
wasm × 2
signing × 2
build × 2
http × 2
installation × 2
cmake × 2