I am trying to write a smart contract but for some reason my tables aren't being added to the abi file and therefore aren't being added to the blockchain.

My code is as follows. Am I possibly declaring the table incorrectly?

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>

using namespace eosio;

class hyperion : public contract
    hyperion(name self, name code, datastream<const char *> ds) : contract(self, code, ds){}

    struct [[eosio::table]] domains
        uint64_t key;            //Primary key
        std::string domain_name; //Domain name
        name owner;              //Owner of the domain
        uint32_t price;          //Cost of the domain

        uint64_t primary_key() const { return key; }

    typedef eosio::multi_index<"domains"_n, domains> domain_index;

    void upsert(name user, std::string domain_name, uint32_t price)
        //Require auth from the user
        //Get the domains
        hyperion::domain_index domains(_code, _code.value);
        //Check if the domain exists in the table
        bool found = false;        
        for (auto itr = domains.begin(); itr != domains.end() && found != true; ++itr)
            if (itr->domain_name == domain_name)
                found = true;
        if (!found)
            domains.emplace(user, [&](auto &row) {
                row.key = domains.available_primary_key();
                row.domain_name = domain_name;
                row.owner = user;
                row.price = price;

EOSIO_DISPATCH( hyperion::hyperion, (upsert) )
  • 1
    The only obvious problem is that you haven't declared that the hyperion class is a contract with [[eosio::contract]]. Try that and if it still doesn't work, then update the question to include the steps you use to build the wasm and abi files please – Phillip Hamnett - EOS42 Mar 20 '19 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.