Tables Programming - Discussion

Jeff at least you passed the " deploy " stage , in my case I can’t pass it , I even tried the website EOSstudio.io to deploy but still no luck , I always get errors even I copied the code from @filip account on GitHub with no modification ,but I keep getting this error " unexpected ned of JSON input " .
this so frustrating I think I will pass on EOS course !

1 Like

Hi, Sam_Asad.

This EOS course is currently being remade, and I would recommend you to complete one of your other courses first, then come back to EOS when Filip is finished with the new and updated course?

I think EOS can be a cool, but still, a challenging language to work with, so I’m afraid you might get a lesser experience if you continue on the course as it is at the moment. :disappointed:

Is there any other course in your personal study plan you might be interested in starting? If you want you could contact me at [email protected] and I’ll be glad to help you choose the right path for you.

Good Luck, my friend. :+1:t2:

Ivo

1 Like

Hi, sorry for the late reply.

Some of the benefits would be fast transaction speed, no transaction fees, and staking, etc, etc. :blush:
I’m sure you will find all their “selling points” and use cases on their homepage. EOS.io

Good luck.
Ivo

thanks for the reply , I think I’m heading to eth programming now and when Eos is ready ill come back to it ,

1 Like

I think that is smart…:wink:
Ivo

Hi Guys,

I quit EOS Studio as it is too buggy for me :wink:
However I have some basic questions :
I believe that "“TABLE” is an “alias” as follow : typedef struct [[eosio::table]] TABLE
what is the meaning of [[eosio::table]] ?
eosio::table i get it but [[ … ]] ?
Is it particular to eosio-cpp ?

Thanks.

1 Like

Hi.
Do you mean why It’s in double brackets?
Ivo

yss IVO why [[ ]] ?
I understand that eosio-cpp implements its own directives for generating wasm and ABI files .
EOS official documentation not very helpful either.

Never tought of it. I can see what I find and come back to you on it. :slightly_smiling_face: Have you done all the other developer courses? EOS is the last in it’s track…
Ivo

1 Like

@lamebrisee the “[[eosio::action]]”, its the syntax that you will use in order to invoke or listen a function directly from eosio smart contracts, the double brackets are used in the syntax of your contract to let the eosio compiler (eosio-cpp) know that your about to invoke that specific function for the code your about to write.

Carlos Z.

2 Likes

Muchas Gracias Carlos :slight_smile:
I am back to Coding and doing that with EOS and C++.
I could not find any explanations with GNU g++ compiler and c++/11/14/17 standards.
You made my day.

JJ.

1 Like

Hi Guys,

As esoio::multi_index wraps boost::multi_index_containers:

I have found very useful to spend additional time studying boost::multi_index_containers and also STL containers.
here s a very good link
https://theboostcpplibraries.com/boost.multiindex

Hope this helps.

JJ.

1 Like

Hi Ivo,
I have started this course back in the days where it was on the previous website.
EOS Smart Contract programming was taught before Etherium.
That s why I stick to it.
Despite a Buggy EOS Studio Environment I have been learning a lot ( especially with C++ ).
I believe Etherium cusrus should be “smoother”.

JJ.

1 Like

FYI: At the end of this Table Programming Part 4 @Phillip_Hamnett says we are next going to talk about indices and then the next thing goes to @filip talking about Tokens :wink:

1 Like

Hello sir, thank you for notice that issue.
Just curious let me know if they talk about indices in further lectures.

Carlos Z.

1 Like

Yes, after the Token lessons it goes back to secondary indices. And then at the end of that lesson group it says we will be talking about Tokens next. So it’s just out of order…

1 Like

Hi Guys,

I have the following error:

jj@nodeOS:~/EOSIO_2.0.0-1/contracts/dogcontractNOtoken$ eosio-cpp -abigen -o dogcontractNOtoken.wasm dogcontractNOtoken.cpp
Warning, empty ricardian clause file
Warning, empty ricardian clause file
/usr/opt/eosio.cdt/1.6.3/bin/wasm-ld: error: fatal failure: contract with no actions and trying to create dispatcher

I cannot figure out why ?
I have used Carlos code ( TheCil )

#include <eosio/eosio.hpp>

using namespace std;
using namespace eosio;

CONTRACT dogcontract : public contract {
public:
using contract::contract;
// dogcontract constructor with initializer list method
dogcontract(name receiver ,name code , datastream<const char*> ds):contract(receiver,code,ds) {}

/*
** Function insert the name and age of a dog with the dog_id.
** Owner can not be changed in this function.
*/

ACTION insert(name owner, std::string dog_name, int age){
      //Require auth of the owner
      require_auth(owner);
      //Get the index of our table
      dog_index dogs(get_self(), get_self().value); //this is an scope
      //Execute the insert function. Specifying the dog_name and age,
      //payer of storage and a lambda function.
      dogs.emplace(owner, [&](auto& row){
        row.id = dogs.available_primary_key();
        row.dog_name = dog_name;
        row.age = age;
        row.owner = owner;
      });

//send_summary(owner, “dog inserted properly.”);

}//End of ACTION insert

private:
//table struct dog
TABLE dog {
int id ; // Unique ID for index
std::string dog_name;
int age;
name owner; //eos account name, owner of dogs
//get primary key by ID variable ; mandatory field for eosio TABLE
uint64_t primary_key() const{ return id ;}
//get dogs by owner index
uint64_t by_owner() const{return owner.value;}

};

// define a eosio::muliti_index container
typedef multi_index<“dogs”_n , dog , indexed_by<“byowner”_n, const_mem_fun<dog, uint64_t , &dog::by_owner >>> dog_index;

};

Thanks much,

JJ.

1 Like

Hello sir, some few steps to follow:

1.you must rename the cpp file to dognotoken.cpp.

2. inside the contract:

rename the CONTRACT class from dogcontract to the same of cpp file. (dognotoken)
In codeline 6 and 9, there are the only 2 few lines to change, from dogcontract to dognotoken

CONTRACT dognotoken: public contract {
  public:
    using contract::contract;
    dognotoken(name receiver, name code, datastream<const char*> ds):contract(receiver, code, ds)

I have faced that weird issue in the past, basically: the contract name should have the same name than the cpp file. So this does the trick. Also, avoid capital letters or signs, could run into issues some times.

I redeploy my dogcontractNOtoken again just to be sure that is working without issue, so you should be able to run it after those few changes.

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Carlos,

You just made my day and i will keep you posted for sure.

Thanjks much,

JJ.

1 Like

Thanks Carlos.
It worked like a charm :slight_smile:

1 Like