Tables Introduction - Discussion

Welcome to the discussion thread about this lecture section. Here you can feel free to discuss the topic at hand and ask questions.

Can someone take a look at my code. I am trying to write an EOS contract listed in the course. When I do, it does not build. I am using a Mac. I misspelled Hello because I was having trouble with the first lesson, I decided to start over. Local Nodes are running. I am getting an abigen error.

Here is the code:



#include <eosio/eosio.hpp>

#include <pet.hpp>

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



#include <hellooworld.hpp>

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


#ifndef PET
#define PET

class [[eosio::table, eosio::contract(“hellooworld”)]] pet_t
uint64_t id;
eosio::name owner;
eosio::name pet_name;
uint64_t age;
eosio::name type; //12 letters lower case 1-5
pet_t() {}

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

uint64_t get_id() const {return id; }
eosio::name get_owner() const { return owner; }
eosio::name get_pet_name() const {return pet_name; }
uint64_t get age() const {return age; }
eosio::name get_type() const { return type; }

uint64_t primary_key() const {return get_id();} //must be used in every table defines how the data is organized and sorted. here it is sorted by ID

EOSLIB_SERIALIZE( pet_t, (id)(owner)(pet_name)(age)(type) )


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

Not sure that my tree is right.

Thanks for any help.