Tables Programming - Discussion

Ok, feeling confident that my code is the same as the video. I have watched it several times, and there is no pet.cpp file. I can be such a coding clutz. ;/ … thanks for bearing with me as I learn, vent and work through this:

I am getting this error message:

It appears that the files that are affected by this malicious message include the hellooworld.hpp file:

#ifndef HELLOOWORLD
#define HELLOOWORLD

#include <eosio/eosio.hpp>

#include <pet.hpp>

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

#endif

and also the hellooworld.cpp file:

#include <hellooworld.hpp>

void hellooworld::hi(eosio::name const & nm)
{
    eosio::print("hello ", nm);
}
1 Like

still stuck. Any help?

1 Like

Hey @dani88, hope you are great.

sorry for the late reply, i think you have an issue on your cpp file, the syntax of your #include <hellooworld.hpp> is not correct, but i’m not 100% sure, I’m not at home but i’m working on my laptop, i’m installing a VM for EOS studio and all EOS related stuffs, then i can test your code be give you a more accurate review.

I’ll let you know what is exactly the error, but i think is a syntax error, the “abigen error” some times appear to me because i have an error on my syntax, maybe a mistype name on a variable, a ; bad placed, or incorrect syntax on header files. I will check and give you an answer.

Carlos Z

1 Like

I checked the video again, and the instructor does not go back to the “helloworld.cpp” file on his machine. To the best that I can tell, it is correct. There is no function on my copy. I can’t go back to the preceding video to see what was on that file. So, If I am missing something, I’d appreciate your help.

1 Like

Hey @dani88, hope you are great.

I have finally able to test your code, the syntax “abigen” error for me is because the name of one of your files is spelled incorrectly in the syntax.

Please check carefully that you are including the same file name.

I manage to compile it succesfully, I just delete the #include <pet.hpp> because is not created yet.

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

Carlos Z.

Hey @dani88, hope you are great.

I have finally able to test your code, the syntax “abigen” error for me is because the name of one of your files is spelled incorrectly in the syntax.

Please check carefully that you are including the same file name.

I manage to compile it succesfully, I just delete the #include <pet.hpp> because is not created yet.

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

Carlos Z.

I deleted the “include” tag that you mentioned, and still get the same error. If it matters, I am using version 2.0.5

is there a way to comment out the “pet” page to see if the problem is in one of the other two?

1 Like

Well I’m using version 2.0.6 without any issue. Myabe you have to try with that one. Or it could be that your installation is corrupted (but I heavily doubt this is the problem).

To comment code you can just use “//”. Or /* ... */ to comment multiple lines that are inside those tags.

image

Carlos Z.

So, I deleted eos studio, and then reinstalled it. When I started the node, I noticed that from the left, the columns begins with a string of numbers. Then, it says “debug” Is this normal?
2.0.6 had the same result.

I didn’t have problems with xcode when I took c++, and I know that this is the compiler used with the software. Since then, I have updated xcode. Xcode works fine. I just tested it.

1 Like

After sleeping again on the problem, I have a work-around. I will try it live instead of locally. That way I will be able to finish the course, and continue to learn about EOS programming.

1 Like

After sleeping again on the problem, I had an idea. There were two options. I could either run a local network on my mac, or I could do it online. I tried to do it online. The instructions for online setup are not accessible to me. I found the hello world project, but when I tried to edit it, I could not. I thought I may be on the wrong network and when I looked, I am on network “Block One”. I don’t know what I am doing, so which network do I choose? Also, is there any other info that I need in order to run code on this platform??

Thanks,

1 Like

Hey dani, maybe is a problem with Mac or Xcode, truly can’t say for sure, what I do in order to don’t deal with issues from the OS compatibility, is to run a linux VM, ubuntu 18.04, I download the EOS Studio and install it and run everything from it, linux give me less problems with EOS Studio locally, then i just have to share a folder between my PC and the VM, then i just use my code editor from my PC and save those files into the shared folder, will automatically available on my VM, then just copy/past the code into EOS Studio and start work it from that point inside EOS Studio.

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

Carlos Z.

So I had this error as well:

transaction declares authority '{"actor":"james","permission":"active"}', 
but does not have signatures for it.

I just created a new key pair (bottom left green key button), and then with the Account button (top right button, right by Network) I made the account name the person/people I want to use as owner/actor.

So to get rid of the error, I had to have the Account button say the name of the owner/actor I was pushing actions for.

1 Like

In pets.hpp, under public is pets supposed to look like

public:
pets_t(){}

or is it supposed to be

public:
pets_t()= delete;

1 Like

I think you are confused with the programming syntax, it should be as the first example you show.

//keyword for public methods, access level to anyone
public:
//function name, () for arguments, {} for function body (the logic)
pets_t(){}

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

Carlos Z.

1 Like

thanks for clearing that up!

1 Like

So I’ve checked my code and I still can’t find out why the table I not being made in the contracts after building it despite having the same code in the videos.

This is the code in my helloworld.hpp:

#ifndef HELLOWORLD
#define HELLOWORLD

#include <eosio/eosio.hpp>

#include <pets.hpp>

CONTRACT helloworld : public eosio::contract
{
  public:
    using eosio::contract::contract;
    ACTION hi(eosio::name const & nm);
    ACTION addpet(uint64_t const id, eosio::name const & owner, eosio::name const & pets_name, uint64_t const age, eosio::name const & type);
};

#endif

this is the code in my helloworld.cpp:

#include <helloworld.hpp>

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

void helloworld::addpet(uint64_t const id, eosio::name const & owner, eosio::name const & pets_name, uint64_t const age, eosio::name const & type)
{
  pets_table pets(get_self(), get_self().value);  
  pets.emplace(get_self(), [&](auto & entry){
    entry = pet_t(id, owner, pets_name, age, type);
  }); 
}

this code is in pets.hpp:

 #ifndef PETS
#define PETS

class [[eosio::table, eosio::contract("helloworld")]] pet_t 
{
    private:
        uint64_t id;
        eosio::name owner;
        eosio::name pets_name;
        uint64_t age;
        eosio::name type;
    public: 
        pet_t(){}

        pet_t(uint64_t const _id,
            eosio::name const & _owner,
            eosio::name const & _pets_name,
            uint64_t const _age,
            eosio::name const & _type) : id(_id), owner(_owner), pets_name(_pets_name), age (_age), type (_type) {}

        uint64_t get_id() const { return id; }
        eosio::name get_owner() const { return owner; }
        eosio::name get_pets_name() const { return pets_name; }
        uint64_t get_age() const { return age; }
        eosio::name get_type() const { return type; }

        uint64_t primary_key() const { return get_id(); }

        EOSLIB_SERIALIZE( pet_t, (id)(owner)(pets_name)(age)(type) )
};

typedef eosio::multi_index< "pets"_n, pet_t > pets_table;

#endif

1 Like

Hey @inzhagey, hope you are well.

Your contract looks fine, I compile it and deploy it successfuly.

If you are wondering about your table, it is here: (pets.hpp)

        pet_t(uint64_t const _id,
            eosio::name const & _owner,
            eosio::name const & _pets_name,
            uint64_t const _age,
            eosio::name const & _type) : id(_id), owner(_owner), pets_name(_pets_name), age (_age), type (_type) {}

Then you define it as “pets” with:
typedef eosio::multi_index< "pets"_n, pet_t > pets_table;

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

Carlos Z.

I don’t know why but I still can’t see a table with the same code I had above.

When I click run again I get this:

1 Like

You have to click on the top left corner button “f(x)hi” which is the button for all the functions contained in your contract, you should be able to see the “addpet” function.

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

Carlos Z.