Basic EOS Programming - Discussion

It does not work because you have not permission to manage “lee” account, do you have the private keys on that account? I this is part of the security measures on EOS, you can’t manage other accounts (like "lee) with a 3rd party account (like helloworld4).

You should add the “lee” account private key to your EOS Studio, then select it to use the functions from the smart contract. The error that you are facing it is because you are trying to manage “lee” account with “helloworld4” account, which is not possible because only the owner of an account can access his data.

Carlos Z.

@filip

hello,

i started the first helloworld compile and deploy and compile. even though it seems to me that my code is the same as in the video i get errors as following:

....................
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:23: error: unknown type name 'name'; did you mean 'eosio::name'?
ACTION helloworld::hi(name from, string message) {
                      ^~~~
                      eosio::name
/usr/opt/eosio.cdt/1.6.3/bin/../include/eosiolib/contracts/eosio/../../core/eosio/name.hpp:35:11: note: 'eosio::name' declared here
   struct name {
          ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:34: error: unknown type name 'string'; did you mean 'std::string'?
ACTION helloworld::hi(name from, string message) {
                                 ^~~~~~
                                 std::string
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/iosfwd:194:65: note: 'std::string' declared here
typedef basic_string<char, char_traits<char>, allocator<char> > string;
                                                                ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:20: error: out-of-line definition of 'hi' does not match any declaration in 'helloworld'
ACTION helloworld::hi(name from, string message) {
                   ^~
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:7:3: error: unknown type name 'messages_table'; did you mean 'std::messages_base'?
  messages_table _messages(get_self(), get_self().value);
  ^~~~~~~~~~~~~~
  std::messages_base
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: 'std::messages_base' declared here
class _LIBCPP_TYPE_VIS messages_base
                       ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:7:18: error: no matching constructor for initialization of 'std::__1::messages_base'
  messages_table _messages(get_self(), get_self().value);
                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class _LIBCPP_TYPE_VIS messages_base
                       ^
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3491:27: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
    _LIBCPP_ALWAYS_INLINE messages_base() {}
                          ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:25:20: error: out-of-line definition of 'clear' does not match any declaration in 'helloworld'
ACTION helloworld::clear() {
                   ^~~~~
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:28:3: error: unknown type name 'messages_table'; did you mean 'std::messages_base'?
  messages_table _messages(get_self(), get_self().value);
  ^~~~~~~~~~~~~~
  std::messages_base
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: 'std::messages_base' declared here
class _LIBCPP_TYPE_VIS messages_base
                       ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:28:18: error: no matching constructor for initialization of 'std::__1::messages_base'
  messages_table _messages(get_self(), get_self().value);
                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class _LIBCPP_TYPE_VIS messages_base
                       ^
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/usr/opt/eosio.cdt/1.6.3/bin/../include/libcxx/locale:3491:27: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
    _LIBCPP_ALWAYS_INLINE messages_base() {}
                          ^
8 errors generated.
Error while processing /tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp.
abigen error
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <hi> does not have a ricardian contract
Warning, action <hi> does not have a ricardian contract
Warning, action <clear> does not have a ricardian contract

this is my code:

#ifndef HELLOWORLD
#define HELLOWORLD

#include <eosio/eosio.hpp> 

CONTRACT helloworld : public eosio::contract 
{ 
  public:    
  using eosio::contract::contract;
  ACTION hi(eosio::name const & nm); 
};

#endif
#include <helloworld.hpp>

void helloworld::hi(eosio::name const & nm) 

{
eosio::print("helloworld", nm);
}

besides is not clear to me which network should i use in web app in windows? block.one, cryptokylin or jungle?

thanks

1 Like

Hey @enrico, hope you are well.

I believe you have not imported your cpp file in the contract helloworld file, (#include <helloworld.cpp>), thats why your contract show part of the errors, the other one is the compiler which is refered to the erros that said “std:string”… are you using 1.6.2 or 1.7.1??

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

hi,

i tried to correct what you said but i still get errors:

...........
In file included from /tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:1:
In file included from include/helloworld.hpp:5:
./helloworld.cpp:3:6: error: use of undeclared identifier 'helloworld'
void helloworld::hi(eosio::name const & nm) 
     ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:23: error: unknown type name 'name'; did you mean 'eosio::name'?
ACTION helloworld::hi(name from, string message) {
                      ^~~~
                      eosio::name
/usr/opt/eosio.cdt/1.6.2/bin/../include/eosiolib/contracts/eosio/../../core/eosio/name.hpp:35:11: note: 'eosio::name' declared here
   struct name {
          ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:34: error: unknown type name 'string'; did you mean 'std::string'?
ACTION helloworld::hi(name from, string message) {
                                 ^~~~~~
                                 std::string
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/iosfwd:194:65: note: 'std::string' declared here
typedef basic_string<char, char_traits<char>, allocator<char> > string;
                                                                ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:3:20: error: out-of-line definition of 'hi' does not match any declaration in 'helloworld'
ACTION helloworld::hi(name from, string message) {
                   ^~
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:7:3: error: unknown type name 'messages_table'; did you mean 'std::messages_base'?
  messages_table _messages(get_self(), get_self().value);
  ^~~~~~~~~~~~~~
  std::messages_base
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: 'std::messages_base' declared here
class _LIBCPP_TYPE_VIS messages_base
                       ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:7:18: error: no matching constructor for initialization of 'std::__1::messages_base'
  messages_table _messages(get_self(), get_self().value);
                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class _LIBCPP_TYPE_VIS messages_base
                       ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3491:27: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
    _LIBCPP_ALWAYS_INLINE messages_base() {}
                          ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:25:20: error: out-of-line definition of 'clear' does not match any declaration in 'helloworld'
ACTION helloworld::clear() {
                   ^~~~~
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:28:3: error: unknown type name 'messages_table'; did you mean 'std::messages_base'?
  messages_table _messages(get_self(), get_self().value);
  ^~~~~~~~~~~~~~
  std::messages_base
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: 'std::messages_base' declared here
class _LIBCPP_TYPE_VIS messages_base
                       ^
/tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp:28:18: error: no matching constructor for initialization of 'std::__1::messages_base'
  messages_table _messages(get_self(), get_self().value);
                 ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class _LIBCPP_TYPE_VIS messages_base
                       ^
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3486:24: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
/usr/opt/eosio.cdt/1.6.2/bin/../include/libcxx/locale:3491:27: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
    _LIBCPP_ALWAYS_INLINE messages_base() {}
                          ^
9 errors generated.
Error while processing /tmp/projects/5fca63068ed3f7003eac89f4/src/helloworld.cpp.
abigen error
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <hi> does not have a ricardian contract
Warning, action <hi> does not have a ricardian contract
Warning, action <clear> does not have a ricardian contract

code is now:

#ifndef HELLOWORLD
#define HELLOWORLD

#include <eosio/eosio.hpp>
#include <helloworld.cpp>



CONTRACT helloworld : public eosio::contract 
{ 
  public:    
  using eosio::contract::contract;
  ACTION hi(eosio::name const & nm); 
};

#endif

i use version 1.6.2

thanks

1 Like

Ok I compile your contract perfectly, you are just missing 2 important modules that solve those errors, which are the namespace to work with EOS syntax correctly (which are imported from #include <eosio/eosio.hpp>)

After the #include mentioned above just add:
In your header file (hpp)

using namespace std;
using namespace eosio;

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Hi Filip

I am struggling to build the cpp file, the hpp seemed to have worked but the hpp come up with this message:
/project/src/hellokae.cpp:3:9: error: field has incomplete type ‘void’

ACTION (hellokae)::hi(name user) {

    ^

/project/src/hellokae.cpp:3:18: error: expected ‘;’ at end of declaration list

ACTION (hellokae)::hi(name user) {

             ^

             ;

/project/src/hellokae.cpp:6:7: error: expected parameter declarator

print("Hello, "), name{user});

  ^

/project/src/hellokae.cpp:6:7: error: expected ‘)’

/project/src/hellokae.cpp:6:6: note: to match this ‘(’

print("Hello, "), name{user});

 ^

/project/src/hellokae.cpp:6:1: error: C++ requires a type specifier for all declarations

print("Hello, "), name{user});

^

/project/src/hellokae.cpp:6:19: error: C++ requires a type specifier for all declarations

print("Hello, "), name{user});

              ^

/project/src/hellokae.cpp:6:29: error: expected ‘;’ at end of declaration list

print("Hello, "), name{user});

                        ^

                        ;

/project/src/hellokae.cpp:7:2: error: expected ‘;’ after class

}

^

;
I am on version v0.13.3

Look forward to hearing from you

1 Like

Hi @Kae_Y, hope you are well.

Now is a little bit complex to read your errors, apparently there are some errors in your code syntax, that way i might need to check your code and i will try to replicate the issue to have a better idea on how to solve those issues.

You can use the “Preformatted Text” Button to encapsulate any kind of code you want to show.


function formatText(){

let words = “I’m a preformatted Text box, Please use me wisely!”

}

prefromatted_text-animated

Carlos Z.

I’m using EOS Studio in Windows and I try following along with the tutorial that is done locally on Linux. I tried creating an account like it asked but a message pops up saying to go to Block.one Testnet to create an account and import private keys. I do this and it still does not allow me to create a count and I can not deploy my contract because it says “Cannot read property ‘map’ of undefined”

1 Like

Hey @bpoletti

You have to follow the instructions of EOS Studio for windows, not for linux, you need to install docker and then EOS Studio should guide you through the installation process.

https://medium.com/@ObsidianLabs/eos-studio-tutorial-1-set-up-the-environment-for-eosio-development-53fe3f9cb1f

Carlos Z

After a week to get EOS installed, I thought I was finally in sync. Apparently not. I got five errors trying to compile the code in the the Basic EOS Programming section of the course. I’m running v2.0.6. My only choices were v2.0.2 thru v2.0.6. My code:

helloworld.hpp:

#ifndef HELLOWORLD
#define HELLOWORLD

#include <eosio/eosio.hpp>

CONTRACT HELLOWORLD : public eosio::contract
{
public:
using eosio::contract::contract;
ACTION hi(eosio::name const & nm);
};
#endif

helloworld.cpp:

#include <helloworld.hpp>

void helloworld::hi(eosio::name const & nm)
{
eosio:print("Hello ",nm);
}

Errors:

In file included from /project/src/helloworld.cpp:1:
include/helloworld.hpp:9:28: error: anonymous struct can only contain non-static data members
using eosio::contract::contract;
^
include/helloworld.hpp:10:12: error: functions cannot be declared in an anonymous struct
ACTION hi(eosio::name const & nm);
^
include/helloworld.hpp:6:1: error: anonymous structs and classes must be class members
CONTRACT HELLOWORLD : public eosio::contract
^
/usr/opt/eosio.cdt/1.6.2/bin/…/include/eosiolib/contracts/eosio/contract.hpp:18:18: note: expanded from macro ‘CONTRACT’
#define CONTRACT class [[eosio::contract]]
^
In file included from /project/src/helloworld.cpp:1:
include/helloworld.hpp:6:1: error: call to implicitly-deleted default constructor of ‘(anonymous class at include/helloworld.hpp:6:1)’
/usr/opt/eosio.cdt/1.6.2/bin/…/include/eosiolib/contracts/eosio/contract.hpp:18:18: note: expanded from macro ‘CONTRACT’
#define CONTRACT class [[eosio::contract]]
^
include/helloworld.hpp:6:23: note: default constructor of ‘’ is implicitly deleted because base class ‘eosio::contract’ has no default constructor
CONTRACT HELLOWORLD : public eosio::contract
^
/project/src/helloworld.cpp:3:6: error: use of undeclared identifier ‘helloworld’
void helloworld::hi(eosio::name const & nm)![helloworld dot cpp|434x132]

Here are screenshots from the course:
helloworld dot cpp

hellpworld dot hpp

1 Like

@filip or @thecil, can I get your help with the above issue?

1 Like

Hey @tbaker, hope you are well.

Sorry for the late reply, I just changed the Contract name from HELLOWORLD to helloworld in your helloworld.hpp file and it compiles good for me, try to do the same and let me know, from my experience, the problem is that the contract name should have the same name as the file, if your file name is helloworld.cpp, the contract name should be helloworld.

Carlos Z

1 Like

When I tried to deploy, it said it could not find home/ted/EOS, but there is an EOS Studio, so I took the space out. Then it said it could not find /home/ted/EOSStudio/helloworld/helloworld.wasm

I noticed there was a file called helloworld.wasm.tmp4e7f81b So I renamed to helloworld.wasm Tried to deploy again and got the same error for helloworld.abi which I’ve never heard of. I could also see that this time it created a helloworld.wasm in the files across the top (not on the left) and inside of it was the message:

Error: readWasm failed:
000000a: error: unable to read u32 leb128: string length
1 Like

When you create a new project on EOS Studio, it create a new folder for that project inside the EOS Studio folder, if you do not set any folder when creating the project, try to delete the project and create a new one on the default folder that EOS Studio suggest, then try to compile and deploy the contract, to test those methods.

image

Carlos Z

ok, I deleted everything from the old project and created a new ‘helloworld’ project. This time when I tried to deploy, I got the same error as shown below. But this time, there is no helloworld.wasm at all anywhere as far as I can tell. Below is all there is. In ‘src’ is the .cpp and in ‘include’ is the .hpp. That’s all that’s there. I should also mention I got this message when I did a build:

docker run --rm --name eosio.cdt_v1.6.2 --volume /home/ted/EOSStudio:/project -w /project eostudio/eosio.cdt:v1.6.2 /bin/bash -c “eosio-cpp -abigen -I include -R resource -contract helloworld -o helloworld.wasm src/helloworld.cpp”
docker: Error response from daemon: Conflict. The container name “/eosio.cdt_v1.6.2” is already in use by container “af1fb28662db30103a03c35b6f0e89b4df0fba930659a03bfff99741edc79355”. You have to remove (or rename) that container to be able to reuse that name.
See ‘docker run --help’.
eos deploy failed
eos folder

1 Like

Ok, this problems happens when your contract syntax have some error and when you compile it (hammer button on EOS Studio) the compiler just get stuck compiling forever.

Thats why you have the error from docker saying there is another instance already running.

Would be great if you can share the code so i can debug it on my PC and check what is missing. :face_with_monocle:

Carlos Z

1 Like

I managed to get docker to stop the previous instance, but when I went to compile, it never finished again.

Here’s the code:
helloworld.hpp:

#ifndef HELLOWORLD
#define HELLOWORLD

#include <eosio/eosio.hpp>

CONTRACT helloworld : public eosio::contract
{
public:
using eosio::contract::contract;
ACTION hi(eosio::name const & nm);
};
#endif

hellowold.cpp:

#include <helloworld.hpp>

void helloworld::hi(eosio::name const & nm)
{
eosio::print("Hello ",nm);
}

It also added .tmp60bcf7a to helloworld.wasm and helloworld.abi is missing

1 Like

Hey @tbaker, hope you are ok.

I have tested your contract and I facing the same issue with EOS Studio, I was not able to solve it, every time i want to compile, it takes forever, never finish to do it.

What i try also was to delete all my EOS Studio projects, restart the entire program, and just create the basic “helloworld” contract that they deploy at the start.

It does not compile even their own contract, so for me its basically a problem with EOS Studio (is not working properly). I can advice you to not loose more time with it and move on with Nodeos & Cleos, which are the same that EOS Studio use but on command line.

You can check how to use Nodeos & Cleos in the course EOS 201. At least try to learn how to use those tools so you can compile/deploy/test your contracts properly.

Carlos Z

1 Like

Hi guys, can anyone help. I keep getting the following error when trying to build the contract in the “hello world - compile and deploy video”, thanks in advance

840s - It took longer than we expected, you may keep waiting or stop it and build it again.
<h2>Internal Server Error, real status: 500</h2>

Me again guys, also having issues when trying to install systems contracts v1.9.2 with the following error message:

git : The term 'git' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included,    
verify that the path is correct and try again.
At line:1 char:1
+ git clone --branch v1.9.2 --single-branch https://github.com/EOSIO/eo ...
+ ~~~
    + CategoryInfo          : ObjectNotFound: (git:String) [], CommandNotFoundExcepti    
   on
    + FullyQualifiedErrorId : CommandNotFoundException

Thanks again

1 Like