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