Questions tagged [c++]

All questions related to the use of C++ within the EOSIO framework

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

Transaction failed - Encoding error at root: Invalid type jsobj, no encoding methods implemented

I am getting this error on a compiled contract on WAX testnet I'm not sure where the error is from, but this file may be the cause. I don't know if it's a missing header file, etc. I can't find `jsobj ...
Douglas's user avatar
  • 101
0 votes
1 answer
17 views

Alternative to std::ifstream for eosio contract

I'm watching for an alternative to "std::ifstream" because "#include " can't include as header in a contract. My code is: std::istream& operator>>(std::istream& str, ...
Eosio's user avatar
  • 1
2 votes
1 answer
108 views

Can I make a http request from smart contract code?

I know that eosio has http plugins, which is why I'm thinking that maybe a http library is embedded to the eosio.hpp and that I can use it internally to send http requests. Is this possible? My goal ...
basilisk's user avatar
  • 131
0 votes
1 answer
53 views

Nested depth exceeded

kipping set abi because the new abi is the same as the existing abi Publishing contract... Error 3070002: Runtime Error Processing WASM Error Details: Nested depth exceeded pending console output: ...
James Cai's user avatar
0 votes
1 answer
60 views

Runtime error (eos-vm system failure) on using C++ `virtual` keyword?

In my contract I have a data structure that involves a node struct and a LeafNode and InnerNode struct that inherit from node. struct node { ... virtual string to_string() const { ...
Taner Seytgaziyev's user avatar
0 votes
1 answer
104 views

Passing struct as a parameter to smart contract action

I want to save data in the blockchain table whose format is as below: { "docsample": { "id": 1, "creationDate": "2012-05-16T18:25:43.511Z", "...
Varsh's user avatar
  • 307
1 vote
0 answers
35 views

Build existing autoconf C project to include in smart contract

I'd like to include GNU's GMP library in my smart contract project. It's an autotools/autoconf project, how can I compile it as a standalone webassembly library and then include it in my smart ...
Guillermo Rodriguez's user avatar
2 votes
1 answer
61 views

how to find greatest common divisor inside smart contract?

I need the greatest common divisor between two numbers in the smart contract. I tried: int gcd = __gcd(num1, num2); num1 and num2 are two numbers. When the smart contract is compiled, its generating ...
Varsh's user avatar
  • 307
1 vote
1 answer
74 views

What is the way to create a map from 256 bit integers to values?

What is the way to create a map from 256 bit integers to values? Is it std::map<>? or will std::map<> become slow as the data grows? If it is slow, what is faster?
porton's user avatar
  • 111
1 vote
1 answer
62 views

Type mismatch error when creating iterator

I'm getting a type mismatch error when I try to execute an action. Here is the line that's causing problems: auto iterator = table.require_find(primary_key, ("Could not find entry " + std::to_string(...
Michael Nash's user avatar
1 vote
1 answer
49 views

Profiling EOS.IO smart contract code

What's the best way for profiling the code of an EOS.IO smart contract? I'd like to know what percentage of the CPU time is spent on executing each function\line (including multi index table function ...
Yogev Mashiach's user avatar
0 votes
1 answer
97 views

Trouble using EOSIO built in crypto library (can't resolve headers)

I ran eosio-init on the newest CDT (1.7) and made a -bare project. newtest.cpp #include "newtest.hpp" ACTION newtest::hi( name nm ) { /* fill in action body */ print_f("Name : %\n",nm); } ...
MegaBeans's user avatar
0 votes
0 answers
47 views

Catch errors when calling deposit

When I send EOS in a contract to several recipients, it can happen that this fails, e.g. because a recipient has a contract running like that: Example contract of one recipient: [[eosio::on_notify("...
elpol's user avatar
  • 1
0 votes
1 answer
145 views

multi_index table get const_iterator at a specific position

is there a better way than a loop to get the value/const_iterator at a specific position in multi_index table? current: auto idx = _table.get_index<"name"_n>(); const_iterator b; int count = ...
sinbad's user avatar
  • 99
1 vote
1 answer
136 views

Is it possible to set up a smart contract with multiple .cpp and .hpp files?

If we want to make our smart contract code modular, and keep each class, contract, and table in its own file, is it possible to do this, and if so, how?
Phillip Hamnett - EOS42's user avatar
1 vote
1 answer
78 views

RPC Wallet integration API throwing an error

I am new with blockchain services. I have created wallet using command line. curl -X POST http://127.0.0.1:8888/v1/wallet/create -d '"WalletTest" It's created successfully. But, I'm trying to ...
msc's user avatar
  • 145
0 votes
1 answer
37 views

what are supported STL types in tables?

What are the supported STL types in tables? I'm specifically curious about std::pair
errolflynn's user avatar
0 votes
1 answer
61 views

template function in contract code with a lambda

This is more a C++ question than EOS contracts question but I am having trouble creating a template function for migrating tables to a different scope. I cannot get this to compile. template <...
Dallas Johnson's user avatar
1 vote
1 answer
465 views

Transfer tokens inside a smart contract from an account to another account

I need to write a simple function that would send tokens using a different account action. Exactly the same situation as in these questions: one and two But I have to use not eosio.token contract but ...
Dim's user avatar
  • 21
1 vote
1 answer
90 views

Defining symbols for a contract at compile time - how?

supposing I have a contract declaration in file t.cpp as follows: class [[eosio::contract("__CONTRACT__")]] token : public contract { I would expect to be able to compile it like this: $ eosio-cpp -...
ekkis's user avatar
  • 515
0 votes
0 answers
21 views

Can I deploy a contract from within a contract? [duplicate]

We can create accounts from contract code: https://github.com/angelol/smart_account_creator and we can query things about accounts: https://github.com/nsjames/Account-Has-Code is there a way to ...
Utgarda's user avatar
  • 101
1 vote
2 answers
74 views

Contract won't keep index count inside index table

Attempting to keep track of an index for future use as an index in another container. uint64_t namehash = ::eosio::string_to_uint64_t(my_name.c_str()); auto name_iter = ...
nakomis's user avatar
  • 23
0 votes
1 answer
177 views

Passing the action name having return type to EOSIO_DISPATCH in EOSIO smart contract

I have following EOSIO smart contract: #include <eosiolib/eosio.hpp> #include <eosiolib/print.hpp> using namespace eosio; class random : public contract { public: using contract::...
Varsh's user avatar
  • 307
0 votes
1 answer
139 views

Does permission_level (_self) means that only contract can use this method?

If yes, then how do I make sure that anyone or any specified address can call a method? If not then what is the usage of permission_level (_self ...)? action{ permission_level{_self, "active"_n}...
kpopguy's user avatar
0 votes
1 answer
200 views

EOSIO: name.value secondary index returns end iterator, even though searched value exists in table

I've got a multi-index table going with two secondary indices: TABLE entry { uint64_t id = 0; eosio::name player; std::vector<uint16_t> allocation; ...
bitgenstein's user avatar
0 votes
1 answer
233 views

How can I create a table in an .hpp for a general contract? (Using the CDT)

THE STRUCTURE OF MY PROJECT I am working in mycontract.cpp, which imports myheader.hpp WHAT I WANT I want to create a table in myheader.hpp, for a generic contract, "IN THEORY" as follows: struct [...
Riccardo Persiani's user avatar
2 votes
1 answer
486 views

Using transfer to send tokens within a smart contract results in "unable to find key"

This is my example code deployed on myaccount #include <eosiolib/eosio.hpp> #include <eosiolib/print.hpp> #include <eosiolib/currency.hpp> using namespace eosio; class ...
colin's user avatar
  • 267
2 votes
1 answer
316 views

Runtime Error Processing WASM in ``` std::stof```?

[[eosio::action]] void hi(){ string strNum; strNum.push_back('3'); float currNum = std::stof(strNum);// print("currNum=",currNum); } ...
Lou Treaser's user avatar
1 vote
1 answer
615 views

How to solve !action_type.empty(): Unknown action hi in contract hello?

I am following this doc: https://developers.eos.io/eosio-home/docs/your-first-contract. This is the hello.cpp contract code which is successfully deployed: #include <eosiolib/eosio.hpp> #...
Riccardo Persiani's user avatar
1 vote
0 answers
103 views

How to solve !action_type.empty(): Unknown action hi in contract hello?

I am following this doc: https://developers.eos.io/eosio-home/docs/your-first-contract. This is the hello.cpp contract code which is successfully deployed: #include <eosiolib/eosio.hpp> #...
Riccardo Persiani's user avatar
0 votes
2 answers
108 views

EOS CDT: where are the *.h and the *.cpp files stored in the filesystem, I need reference to them to compile

I'm trying to use the EOS CDT (contract development toolkit). I've downloaded and installed the repository from github, and used to following commands, as indicated from the eos.io development page. ...
Luther's user avatar
  • 175
2 votes
2 answers
850 views

How to solve fatal error: 'eosiolib/types.hpp' file not found #include <eosiolib/types.hpp>?

After installing eosio.cdt 1.4.1, I am receiving this error from the compilation of my code where is included the header file eosiolib/types.hpp: fatal error: 'eosiolib/types.hpp' file not found #...
Riccardo Persiani's user avatar
1 vote
1 answer
240 views

How can i solve the error: iostreams currently clash with eosio::datastream?

I am trying to compile some code which compiled successfully with the old compiler eosiocpp, but with the new eosio-cpp gives me: eosio.cdt/1.4.0/bin/../include/libcxx/iostream:13:2: error: "iostreams ...
Riccardo Persiani's user avatar
2 votes
3 answers
307 views

Can I use uint256_t in EOS smart contracts?

I want to use uint256_t in my EOS smart contract but I am getting following error unknown type name 'uint256_t'; did you mean 'uint16_t'? I thought EOS supports uint256_t as I read it in some EOS ...
Vivek Kumar's user avatar
1 vote
2 answers
251 views

Error 3015004 when creating tokens in tutorial

Caseys-MBP:eosio.token casey$ cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active Error 3015004: The type defined in the ABI is invalid Error Details: ...
nakomis's user avatar
  • 11
3 votes
1 answer
193 views

eosio.cdt 1.3.2 indexed_by error: non-type template argument is not a constant expression

I'm trying to shift my contract and build it with the latest CDT, v1.3.2. The transition docs say to use the new ""_n name constructor but it doesn't appear to be working. I have: typedef ...
James Hollister's user avatar
3 votes
2 answers
293 views

How to handle exceptions in the smart contract?

Let's say I need to send some EOS to 2 different addresses from within a smart contract! Now, let's suppose that one of those addresses is actually a smart contract and can reject the transfer! In ...
Vivek Kumar's user avatar
3 votes
1 answer
494 views

Why smart contract function fails with "Error 3090004: Missing required authority"?

WHAT I WANT From the contract mycontract I want to call a function function1. The function function1 calls another function of mycontract called function2. The function function2 calls an action of ...
Riccardo Persiani's user avatar
3 votes
1 answer
609 views

Whats the use of EOSLIB_SERIALIZE?

I understand that it is used for serialization and deserialization of a struct but why does anybody want to serialize/deserialize the struct? What's the use case?
Vivek Kumar's user avatar
1 vote
1 answer
83 views

How do I use C++11 on Mac?

I tried the hello world sample contract, and when it came time to compile, I got this error: hello.cpp:10:10: error: expected ']' [[eosio:action]] ^ ...
philipkd's user avatar
  • 111
0 votes
1 answer
973 views

How to pass a list / array / vector to an action? [duplicate]

I need to pass a list of integers to an action. It would be fine to use vectors or arrays, but I can't find one that works. Using vector in the smart contract compiles fine, but then I get this error ...
Max's user avatar
  • 411
1 vote
1 answer
877 views

Assertion failure after updating a smart contract with tables

Before the update Before the update of the code of my c++ smart contract, this uses to work absolutely fine. Data storing on the table and actions execution were done successfully. After the update ...
Riccardo Persiani's user avatar
1 vote
1 answer
152 views

Smart contract error while calling recover_key

Specs I am using the function recover_key from the library crypto.h at the following link: https://github.com/EOSIO/eos/blob/master/contracts/eosiolib/crypto.h Code int compressed_size = ...
Riccardo Persiani's user avatar
1 vote
1 answer
162 views

How to parse iso8601 to eos time format?

How does one parse an iso8601 string to eos time_point format?
Vivienne Fosh's user avatar
0 votes
2 answers
2k views

Transfer EOS tokens inside a smart contract from an account to another

I want to implement, in my smart contract(C++), a function that forwards EOS token to another account. This is actually a basic question, but is that possible actually? Please, could you share the ...
Riccardo Persiani's user avatar
1 vote
1 answer
135 views

Time dependent EOS unit test

My contract has time dependent actions, which I want to test. How can I mock the clock in the smart contract such that I can set it to any time I want? An example of one action that is time ...
mbsff's user avatar
  • 93
3 votes
2 answers
168 views

Do all Smart Contracts use the eosio namespace?

I'm new to creating Smart Contracts on EOS and I've followed a few tutorials (for example the official Hello World guide). Would someone be able explain why all of the examples seem to use the ...
SteveJaxon's user avatar
2 votes
2 answers
135 views

How to use std::tuple with eosiocpp?

I am trying to use typedef std::tuple<double, double> location_t; to create a simple tuple with latitude and longitude, but eosiocpp gives me 2018-09-02T12:54:47.310 thread-0 main.cpp:105 ...
Vivienne Fosh's user avatar
2 votes
0 answers
242 views

What are the main differences betwen EOSIO multi_index and Boost multi_index?

Inspired by this comment, I was wondering what are the main differences between eosio::multi_index and boost:multi_index and why do they exist? The documentation notes that there are important ...
confused00's user avatar
  • 5,554
3 votes
1 answer
2k views

What's the difference between "time" and "time_point_sec"?

Seems that they are both datatype for storing number of seconds that have elapsed since 1970. So what's the difference between them, when should I use which? Edit: An example of the "time" datatype I'...
mochunhei's user avatar
  • 277