Hot answers tagged

11

eosiocpp currently compiles contracts using c++14. cib compiles contracts using the c++17 language, but c++14 library. sandboxing: contracts are compiled to WASM. Normal OS functions (filesystem, threading, etc.) are not available. Note: cib requires an up-to-date Firefox (fastest) or Chrome (slow loading).


5

Today I'm using Visual Code (which works in Linux, because I'm on OSX) but I think the easiest one to setup with a nice intellisense (autocomplete), debug and tests is CLion from Jetbrains. In this workshop Kevin Heifner teaches how to setup the IDE: https://objectcomputing.com/resources/events/webinars/building-apps-with-eos/recording


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

Actually asset is a struct variable like this: struct asset { /** * The amount of the asset * * @brief The amount of the asset */ int64_t amount; /** * The symbol name of the asset * * @brief The symbol name of the asset */ symbol_type symbol; ... ... } we ...


3

The problem is that the code you have written is somehow accessing both the standard C++ definition of time (from /usr/include/time.h) and also the EOS.IO definition of time (from ../eosiolib/types.h). All I can think is that something in the building of the system has conflicting include paths. Unless you are doing someting like: #include "time.h" (which ...


3

The code for Boost is in https://github.com/EOSIO/eosio.cdt/tree/master/libraries/boost The main EOS library is eosiolib, and it uses Boost in action.hpp, dispatcher, datastream, etc.


3

Contracts are in WASM which is a compiled binary language. The only currently tested and validated language for EOS smart contract development is C++, but in theory any language that compiles down to WASM can be used. There is an active community effort to support TypeScript as well.


2

Updated answer: Currently EOS smart contracts are written in C++17. For more details see the official SDK, CDT (Contract Development Toolkit) which is based on clang 7.


2

With eosio.cdt, it is now possible to compile object code which can then be tested using unit tests. Check out https://eosio.github.io/eosio.cdt/1.5.0/guides/native-tester.html for a detailed guide. Below is the quoted text from the link at the time of writing this answer (in case the web page is moved or something) Native Tester/Compilation As of ...


2

time is just a typedef for uint32_t, so it has no time-related functionality or restrictions¹ as long as you don't try to represent milliseconds (which you will need if you try to represent block time, as blocks are created every 500ms,) and it's very light to use inside smart contracts, but it doesn't play nice with other time types in eosio. time_point_sec ...


2

You cannot use functions from ./libraries/chain/asset.cpp directly in your contract. The only available part of EOS API you can use in contacts is located in ./contracts/eosiolib/ folder. There are files, which define "asset" and "symbol" structure, but there are no functions, that convert values to string. So, you need to use your implementation inside the ...


2

eosiolib uses the eosio namespace to avoid collisions when imported in a different scope--this is standard programming practice and is not specific to EOSIO. The using namespace <name> directive only brings that namespace in the current scope in order to avoid overusing the scope-resolution operator ::. How you actually use it in the end is just a ...


2

This example does not work: void show(const std::string& time_str) { const time_point& current_time = time_point::from_iso_string(time_str); print(current_time.elapsed._count); } time_point::from_iso_string was cut out from eos time_point. According to this issue one should not parse strings in smart contract at all. As instead, binary ...


2

First of all you need to provide the permission of eosio.code. After that you can use the transfer action of eosio.token contract. before assigning tokens see if both .abi and .wast file are there, if they are not you need to generate .abi and .wast file of eosio.token that can be done like this: # eosiocpp -o ./contracts/eosio.token/eosio.token.wast ./...


2

Use the following code in your smart contract to initiate a transfer of EOS tokens. asset quantity = asset( 10000, symbol_type(S(4, EOS)) ); // equals to 1 EOS action( permission_level{ _self, N(active) }, N(eosio.token), N(transfer), std::make_tuple(_self, to, quantity, string("some memo here")) ).send(); Also note that you will need grant ...


2

Setting up a development environment is simple, just follow the first page of the wiki, here: https://github.com/EOSIO/eos/wiki/Local-Environment


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

It is possible: Set up a new smart contract environment using eosio-init: eosio-init -project=mycontract -path=. Create all of your .cpp and .hpp files as appropriate In the ./src folder, edit the CMakeLists.txt file by adding all of the .cpp files to the add_contract command, making sure that the file containing your contract class is the last file in ...


1

There is no exception handling in web assembly, therefore you can't implement it in the C++ code either


1

The issue was inside an emplace(). Basically, I was not setting the payer. After, hard coding the payer as N(mycontract), I don't get the error anymore and the functions work correctly.


1

EOSLIB_SERIAlIZE is a DataStream Seralizater , if you want to deep dive into what it does you should go to contracts/eosiolib/serialize.hpp in your EOS directory. It basically gives the struct extra operators for the serialization and deserialization of data to and from the multi_index database. if you go deep inside this you will found that it was using ...


1

It took me a while, but I finally solved the issue. Searching on Google for this kind of error, the most interesting source I was able to find was the following: https://github.com/EOSIO/eos/issues/4394. The issue described at the link is not the same as mine, but actually suggested me that there was something wrong when calling an action, from a smart ...


1

You can use timestamp to have this functionality. You can use now() this function will return you current timestamp(in seconds),you can set your own timestamp with help of this function Let say for example you want to increase timestamp by 24 hour then you can simpally do it by now() + 84600.


1

Multiple inheritance not supported for this particular case means that you can only have a tuple of single type. typedef std::tuple<double> location_t; According to this answer one is not able to use tuple. Can somebody also confirm that this is the case? Just replaced tuple with struct to avoid this headache. It's weird that tuple is used ...


1

I hope this can help double stringtodouble(string str) { double dTmp = 0.0; int iLen = str.length(); int iPos = str.find("."); string strIntege = str.substr(0,iPos); string strDecimal = str.substr(iPos + 1,iLen - iPos - 1 ); for (int i = 0; i < iPos;i++) { if (strIntege[i] >= '0' && strIntege[i] <= '9') { dTmp = dTmp * 10 + ...


1

I recently had this problem. I discovered that atoi() actually works (nothing else did). so I wrote it like this: float token::stof(std::string s, float def) { if (s == "") return def; std::size_t i = s.find("."); int digits = s.length() - i - 1; s.erase(i, 1); return atoi(s.c_str()) / pow(10, digits); }


1

The way to do this with the cl would be to go: cleos get table <contract> <scope> <table> contract TEXT - The contract who owns the table scope TEXT - The scope within the contract in which the table is found table TEXT - The name of the table as specified by the contract abi Example: $ cleos get table eosio.token eosio accounts { "...


1

UPDATE: Based on the details you provided in the comments, I think the error might be coming from how you are compiling the code. You said you are running these commands: eosiocpp -o mycontract.wasm *.cpp eosiocpp -o mycontract.wast *.cpp eosiocpp -g mycontract.abi mycontract.cpp when you should actually be running these: eosiocpp -o mycontract.wast ...


1

You can use EOS Studio. Supports Mac, Windows, and Linux https://www.eosstudio.io/ Highlight and autocomplete for EOSIO specific syntax Templates of system contracts: eosio.token, eosio.msig, etc One click to build smart contracts Deploy to local, Kylin/Jungle testnet, or EOSIO mainnet Show build errors inline They have tutorials as well: https://medium....


1

Eclipse Using Eclipse works just fine for me. In order to get it to see all of the appropriate header files, you have to make a symbolic link to the correct folder. For example, if I want to use the hello contract from my home directory: ~/hello/hello.cpp I would do the following: cd ~/hello ln -s /path/to/eos ln -s /path/to/boost Then in Eclipse I ...


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