Basic EOS Programming - Discussion

Nice… How did you solve it?

I had to use some code from fillip and kept deploying code until it work.

1 Like

Hi cherrybluemoon. Im getting the same ‘basic EOSIO smart contract’ template code when I create my first helloworld project in eosstudio cloud network.

What did you find you had to do differently from filips tut to make progress?

Hi @filip .
The helloworld code is very different now it seems:

#include <helloworld.hpp>

ACTION helloworld::hi(name from, string message) {
  require_auth(from);

  // Init the _message table
  messages_table _messages(get_self(), get_self().value);

  // Find the record from _messages table
  auto msg_itr = _messages.find(from.value);
  if (msg_itr == _messages.end()) {
    // Create a message record if it does not exist
    _messages.emplace(from, [&](auto& msg) {
      msg.user = from;
      msg.text = message;
    });
  } else {
    // Modify a message record if it exists
    _messages.modify(msg_itr, from, [&](auto& msg) {
      msg.text = message;
    });
  }
}

ACTION helloworld::clear() {
  require_auth(get_self());

  messages_table _messages(get_self(), get_self().value);

  // Delete all records in _messages table
  auto msg_itr = _messages.begin();
  while (msg_itr != _messages.end()) {
    msg_itr = _messages.erase(msg_itr);
  }
}

EOSIO_DISPATCH(helloworld, (hi)(clear))

And upon building, I get the error …

 eosio-cpp -abigen -I include -R resource -contract helloworld -o helloworld.wasm src/helloworld.cpp
<h2>Internal Server Error, real status: 500</h2>

I notice you got an uppercase H upon the created helloworld project file, even though you used lowercase h when typing in the title. My newly created helloworld project name remained lowercase. Does that suggest anything?

I am running eosstudio cloud network, have chosen CDT v1.6.2, and have selected Account ‘jaybee’ (my newly added account).

Im on a win10 home edition laptop with 8gb ram, but chose the cloud version as eos studio said if it was not the win10 professional os then you would encounter docking issues regarding installations.

Can you help? As this tut seems out-of-date, i’m concerned future tuts will require constant research and tweaking in order to just be able to do the lessons. Can’t you remake this/these lessons so they make sense to newcomers?

Hi. I just ran this code in the eos.studio web version, and i get i to work.
I got the same error message when i tried to buid it, but it still worked when i deployed it… :slight_smile:

I havent had any other issues with the versions i’ve used for this 101 course. :slight_smile:

Ivo

This is my code… :slightly_smiling_face:

#include <helloworld.hpp>

ACTION helloworld::hi(name from, string message) {
  require_auth(from);

  // Init the _message table
  messages_table _messages(get_self(), get_self().value);

  // Find the record from _messages table
  auto msg_itr = _messages.find(from.value);
  if (msg_itr == _messages.end()) {
    // Create a message record if it does not exist
    _messages.emplace(from, [&](auto& msg) {
      msg.user = from;
      msg.text = message;
    });
  } else {
    // Modify a message record if it exists
    _messages.modify(msg_itr, from, [&](auto& msg) {
      msg.text = message;
    });
  }
}

ACTION helloworld::clear() {
  require_auth(get_self());

  messages_table _messages(get_self(), get_self().value);

  // Delete all records in _messages table
  auto msg_itr = _messages.begin();
  while (msg_itr != _messages.end()) {
    msg_itr = _messages.erase(msg_itr);
  }
}

EOSIO_DISPATCH(helloworld, (hi)(clear))

I hope this helps!

Upon building, i’m getting ‘Deploy failed! Unexpected end of JSON input.’.

And that is even after I copied your code into .cpp!?

Is it the first time you run it? Are you sure you are deploying to the right account?

I cant replicate the error you get…

Can you please share the .hpp file to? :slight_smile:
Ivo

The helloworld project compiled successfully but neither the .abi nor the .wasm files were created and so the DEPLOY did not work.

No, I’ve compiled several times now. Yes i’m leaving the contracts as eosio, and account is on my created ‘jaybee’ account name.
Heres the .hpp:

#include <eosio/eosio.hpp>

using namespace std;
using namespace eosio;

CONTRACT helloworld : public contract {
  public:
    using contract::contract;

    ACTION hi(name from, string message);
    ACTION clear();

  private:
    TABLE messages {
      name    user;
      string  text;
      auto primary_key() const { return user.value; }
    };
    typedef multi_index<name("messages"), messages> messages_table;
};

In .wasm im getting:

Error: readWasm failed:
0000000: error: unable to read uint32_t: magic

Im looking on google but cant find related solution. Very frustrating as all courses went well up to this point lol.

1 Like

@JasonB I am still troubleshooting the issue eosio-cpp -abigen -I include -R resource -contract hellotable -o hellotable.wasm src/hellotable.cpp I cannot get passed this. Each time there is a error msg. Also I cannot compile wiith eosio-cpp
There seems to be bugs.

I know. I understand filip has had to redo these vids a few times because of Eos updating their platform. But we NEED up to date tutorials in order to learn! I hope they address this issue soon, as currently, the Eos 101 module is no use to new developers.

1 Like

I am now getting a compile error ::

Here is the .cpp file ::

Here is the .hpp file ::

Totally agreed. Almost like why did we pay for a course that doesn’t work :mask: But hopefully filip is on it.

A polite request for @filip and @ivan.

Please assess the latest Eos network update as the current Basic EOS Programming teaching material is causing many of us students problems. The code in filips tuts is completely different to the Eos helloworld smart contract template that is produced, which will not build and deploy like in the tutorial.

Many of us have correctly come to this forum thread for help, but many others have probably just given up, feeling that they have done something wrong or just cant get it. I get that @filip is busy and probably fed up with having to update this topic in particular lol, but its essential for us newcomers.

2 Likes

Hi.
Your .hpp file is ok. :wink:

in your .cpp file you have the error.
can I ask which lesson you are currently in? In my cpp file I don’t have the print statement, I only have the in the .cpp file. see below.

I just ran your code one more time and it still works… look below…


I even left a message for you on the Blockchain. :slight_smile:

I can’t figure out why it don’t work when you try it. :thinking:
Are you sure both the contract and the account are the same?
Ivo

Hi @JasonB, I understand it’s frustrating when you get stuck with stuff like this. I know how buggy EOS can be sometimes. I’ve also tried to run your code and it works fine for me in eos studio as well. So I’m not sure what’s wrong here, but I’m sure you and @ivga80 will find the solution.

We are working on an update to the Eos course and it will be released in the near future. However, the differences in the actual code between eos cdt 1.6.2 and 1.7 are very small. The biggest difference is mainly that eos studio has changed their example code. So as long as you get past this hurdle, your knowledge of eos programming will still be very very good and you will be able to move on to EOS 201 and so on.

We will of course continue to support you no matter what! I really want you to progress and I’m looking forward to see you in the EOS 201 course soon :slight_smile: