Questions tagged [c++]

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

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

Detailed EOS transaction signature

I want to know exactly how the final EOS transaction signature is built. I use C++ but it could be any language. I can't find any detailed documentation about it. I'm really not sure of what I found ...
1
vote
1answer
25 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?
0
votes
1answer
13 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(...
1
vote
1answer
22 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 ...
0
votes
1answer
36 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); } ...
0
votes
0answers
33 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("...
0
votes
1answer
51 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 = ...
0
votes
0answers
19 views

EOSIO - HttpClient return 201 response code

Using json-rpc-cpp library, I am creating EOS Wallet using wallet RPC. HttpClient *temp = new HttpClient("http://127.0.0.1:30031/v1/wallet/create"); string res; string str = "testwallet1"; temp->...
1
vote
1answer
44 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?
1
vote
1answer
53 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 ...
0
votes
1answer
31 views

what are supported STL types in tables?

What are the supported STL types in tables? I'm specifically curious about std::pair
0
votes
1answer
32 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 <...
1
vote
1answer
146 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 ...
1
vote
1answer
45 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 -...
0
votes
0answers
17 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 ...
0
votes
1answer
42 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 = ...
0
votes
1answer
92 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::...
0
votes
1answer
105 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}...
0
votes
1answer
147 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; ...
0
votes
1answer
154 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 [...
1
vote
1answer
211 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 ...
1
vote
1answer
217 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); } ...
1
vote
1answer
419 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> #...
1
vote
0answers
88 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> #...
0
votes
2answers
63 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. ...
2
votes
2answers
567 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 #...
1
vote
1answer
150 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 ...
1
vote
2answers
175 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 ...
1
vote
2answers
177 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: ...
3
votes
1answer
167 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 ...
2
votes
2answers
156 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 ...
3
votes
1answer
277 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 ...
3
votes
1answer
416 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?
1
vote
1answer
59 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]] ^ ...
0
votes
1answer
586 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 ...
1
vote
1answer
552 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 ...
1
vote
1answer
109 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 = ...
1
vote
1answer
122 views

How to parse iso8601 to eos time format?

How does one parse an iso8601 string to eos time_point format?
0
votes
2answers
1k 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 ...
1
vote
1answer
113 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 ...
3
votes
2answers
138 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 ...
2
votes
2answers
89 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 ...
2
votes
0answers
207 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 ...
3
votes
1answer
1k 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'...
5
votes
3answers
1k views

How to convert asset to string in a contract?

How to convert asset to string in a contract? asset my_asset = asset(10000, S(4, EOS)); string my_asset_string = ??? //How to convert my_asset to a string "1.0000 EOS"?
1
vote
1answer
199 views

Is it possible to compile a smart contract using g++ or clang?

I want to write and execute some unit tests on a smart contract outside of nodeos, but to do that I need to be able to compile the code the normal C++ way, using g++ or clang, so that I get object or ...
0
votes
2answers
767 views

Convert string to float or double

I am trying to convert a string to a float or double, however none of the standard C/C++ methods seem to work. I have tried: atof strtof strtod sscanf In each case, I get an error message when ...
1
vote
1answer
101 views

How to retrieve data from multi index table? i a=have stored data dynamically using emplace method now how to get it back as a Record?

I have used this code to store the data(name and marks) in the table, now i want to retrieve that data in the form of record. how can i get that? void addmarks(account_name examiner, account_name ...
1
vote
1answer
186 views

Error 30700002: Smart contract's apply function not exported; non-existent; or wrong type

I have written a smart contract and I want to start testing it, it contains an apply function, which currently checks for a transfer, and then calls the appropriate function: void mycontract::apply(...
2
votes
3answers
1k views

Which IDE can I use for EOS C++ source code?

What I need is an IDE as advanced as Eclipse, that would tell me if certain imports are missing, variables not declared, compile errors, and so on... I am using Linux so Visual Studio won't work for ...