EOS Hello World Discussion


#1

Welcome to the thread about EOS Hello World. Here you can discuss everything about the Hello World code and potential problems that you might stumble upon.


#2

My CMakeLists.txt is showing up red in its tab and there is an error when I try to deploy the contract. I do not see any typos. Help?

file(GLOB ABI_FILES “*.abi”)
configure_file("{ABI_FILES}" "{CMAKE_CURRENT_BINARY_DIR}" COPYONLY)

add_wast_executable(TARGET HelloWorld
INCLUDE_FOLDERS "{STANDARD_INCLUDE_FOLDERS}" LIBRARIES libc libc++ eosiolib DESTINATION_FOLDER {CMAKE_CURRENT_BINARY_DIR}
)


#3

The CMake file could show up red sometimes in CLion. Sometime it helps to restart it. What’s the error you got when deploying?


#4

I do not know what I did different, but the error went away.


#5

While Filip had us use CLion, you can use a text editor and write your program this way, and afterward invoke eosiocpp for compilation to wasm & abi. CLion for me just got in the way. He also suggested Atom as an IDE, if you like color sensing and more advanced tooling.


#6

1.) What is the “eosio” account that gets referenced? From my own research, it appears that this is an authorizing account used to bootstrap EOSIO nodes. But I’d like more info. if it’s available. Is this pseudo account native to every EOS blockchain? Is this a pseudo account that makes use of the private key listed in the genesis.json file?

I bring up “eosio” here because we need to use it to create a new account, to which we deploy our contracts.

2.) What is “name” exactly from this contract? Is it a custom variable type created by EOS? And why do we wrap “user” around it in our hello world example? e.g. name{user}


#7

Okay, I understand what “name” is referencing now.
This below is from the EOSIO source repo.

struct name {
      operator uint64_t()const { return value; }

      // keep in sync with name::operator string() in eosio source code definition for name
      std::string to_string() const {
         static const char* charmap = ".12345abcdefghijklmnopqrstuvwxyz";

         std::string str(13,'.');

         uint64_t tmp = value;
         for( uint32_t i = 0; i <= 12; ++i ) {
            char c = charmap[tmp & (i == 0 ? 0x0f : 0x1f)];
            str[12-i] = c;
            tmp >>= (i == 0 ? 4 : 5);
         }

         trim_right_dots( str );
         return str;
      }

      friend bool operator==( const name& a, const name& b ) { return a.value == b.value; }
      account_name value = 0;

   private:
      static void trim_right_dots(std::string& str ) {
         const auto last = str.find_last_not_of('.');
         if (last != std::string::npos)
            str = str.substr(0, last + 1);
      }
   };
   /// @}

#8

Hi Siege17, I couldn’t get CLion to work and am using Atom, which seems to work fine. Can I ask how I would build after making change? I used Codeblocks during the C++ portion of this course and everything (inc CLion) is automated (click button). Any help would be highly appreciated. Thanks


#9

I installed cmake packages in atom, but now getting errors:
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.12 or higher is required. You are running version 3.10.2

when I ‘sudo apt-get update’, I get nothing to update?

Any help help from anyone would be greatly appreciated.

Cheers,
kuki


#10

Okay, so I’ve updated cmake to 3.12. Now I can’t build ‘sudo make install’ in the ~/eos/build directory. I get “nothing to build”

Any help is highly appreciated. Thanks


#11

I think you can simply use the eosiocpp command line tool to compile it to wasm and abi. That should be enough.


#12

getting an error

eos/contracts/hello$ eosiocpp -o hello.wast hello.cpp
In file included from hello.cpp:1:
In file included from /usr/local/include/eosiolib/eosio.hpp:7:
In file included from /usr/local/include/eosiolib/action.hpp:7:
/usr/local/include/eosiolib/datastream.hpp:9:10: fatal error: ‘boost/container/flat_map.hpp’ file not found
#include <boost/container/flat_map.hpp>

tried doing the eos/build sudo make install again. and did brew install boost. anyone have some other ideas on what might be going wrong?


#13

Was the eos installation successfull or did you get any errors?


#14

installation seemed fine, when i run the test i get errors

27/41 Test #27: unit_test_binaryen …***Failed 104.31 sec
28/41 Test #28: unit_test_wavm …***Exception: SegFault386.63 sec
34/41 Test #34: nodeos_run_test-mongodb …***Failed 0.31 sec

also having lots of problems with nodeos, always getting block log configuration errors. So i used a walkthrough for the multinode test and that seemed to start producing blocks, it crashed. Right now i can’t get either to work.


#15

I’m not sure what’s causing that unfortunately. I will do some research and see if I find something. In the meantime I would recommend you to check out the lecture about the eos test/main net. So that you could continue with the eos section using the testnet instead of local.


#16

ok thanks, i might try installing a virtual machine on my other computer and see if i run into the same issues


#17

I’m running Ubuntu as VM. EOS builds fine and single node produces blocks, so no problem up till now. But once HelloWorld sample created as shown in the lecture I’m unable to build EOS. I’m getting all sort of errors. These are all originated from very first line in HelloWorld.cpp which is exactly same as ‘hello.cpp’
#include <eosiolib/eosio.hpp>

I’m getting following errors:
In file included from /usr/include/features.h:424:0,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdint.h:26,
from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
from /home/navi/eos/contracts/exchange/../eosiolib/types.h:7,
from /home/navi/eos/contracts/exchange/../eosiolib/types.hpp:6,
from /home/navi/eos/contracts/exchange/../eosiolib/eosio.hpp:6,
from /home/navi/eos/contracts/HelloWorld/HelloWorld.cpp:1:
/usr/include/time.h:75:38: error: ‘time_t time(time_t*)’ redeclared as different kind of symbol
extern time_t time (time_t *__timer) __THROW;

    /home/navi/eos/contracts/exchange/../eosiolib/types.hpp:13:17: error: ‘vector’ in namespace ‘std’ does not name a template type
        typedef std::vector<std::tuple<uint16_t,std::vector<char>>> extensions_type;
                 ^~~~~~
/home/navi/eos/contracts/exchange/../eosiolib/types.hpp: In member function ‘bool std::less<checksum256>::operator()(const checksum256&, const checksum256&) const’:
/home/navi/eos/contracts/exchange/../eosiolib/types.hpp:142:17: error: ‘memcmp’ was not declared in this scope
          return memcmp(&lhs, &rhs, sizeof(lhs)) < 0;

/home/navi/eos/contracts/exchange/../eosiolib/print.h:86:26: error: ‘int128_t’ does not name a type; did you mean ‘int32_t’?
    void printi128( const int128_t* value );
/home/navi/eos/contracts/exchange/../eosiolib/fixed_key.hpp:94:37: error: ‘word_t’ was not declared in this scope
          fixed_key(const std::array<word_t, num_words()>& arr)

There are few other errors similar to the above complaining about print(), begin(), uint128_t etc. Any help will be much appreciated.


#18

Did you execute the command “sudo make install” after building eos?


#19

Thanks, Filip. Yes, i must’ve missed that. It works now. Thanks a lot.


#20

finally able to compile hello.abi took me awhile.

had to run a VM on my new computer. Not sure why old computer has 8gb of ram, but it is over 5 years old

Then change my bios settings to allow for virtual machines

after installation still had problems with compiling hello.wast, used the commands

cd $HOME/eos
git revert -n 67393d7
./eosio_build.sh
cd build
sudo make install

software really pisses me off sometimes, i spent a few days trying to get this to work. Always seems like fixing one thing leads to more problems.