EOS Hello World Discussion

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.

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}
)

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

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

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.

1 Like

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}

1 Like

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);
      }
   };
   /// @}
1 Like

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

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

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

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

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?

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

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.

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.

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

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.

Did you execute the command ā€œsudo make installā€ after building eos?

Thanks, Filip. Yes, i mustā€™ve missed that. It works now. Thanks a lot.

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.