Problems with EOS Studio

OK, here’s the issue. It appeared to me initially that the helloworld code from the 101 course was being used in 201. I now realize that although the code in 201 is very similar, it’s for dogs rather than pets and is not the same. But nowhere in the 201 course is this mentioned. And although you provided me with the 201 code from GitHub, it’s only the dogcontract.cpp file and this is an entirely new contract. So I need to know how to set up this contract, presumably in EOS Studio Isn’t there at least a dogcontract.hpp file as well? I’m also not sure whether I should be using the dogcontractTOKEN.cpp code or the dogcontractNOTOKEN.cpp at this point.

1 Like

The cpp file is your main file for the contract, you could type all the functions on that one or use header files hpp that contain some of the logic that cpp will use.

I have made a more advance contract to show some functionalities outsite of the course scope, you can look at it as an example on how to use hpp files.
https://github.com/thecil/public/tree/master/EOS

But at the moment of compiling the contract with eosio you just need to specify the cpp.

Let me know if you have any question, i know it can be confusing moving from 101 to 201 for this course.

Carlos Z

1 Like

In the lower section here, you can see exactly what I did and what came back. I still have a blinking cursor after 30 minutes. A dogcontract.wasm.tmp... file was created again with the extra .tmp…, like when I tried to compile within EOS Studio, but instead of one line of garbage, I have many pages.

I verified using a spreadsheet that what is in the .cpp file is exactly what you have in GitHub.

I killed the process and attempted one more time with the same result.

Then at the bottom it’s more coherent and it references some of the actions in the contract. I’ll leave this here just in case it means anything:

action_data_sizeread_action_dataeosio_assert_codeeosio_assertrequire_authdb_find_i64
db_get_i64
db_update_i64current_receiverdb_store_i64db_lowerbound_i64
db_end_i64db_previous_i64db_idx64_storedb_next_i64
db_remove_i64db_idx64_find_primarydb_idx64_removedb_idx64_updatedb_idx64_lowerbound
db_idx64_next
ted@ted-VirtualBox:~/EOSStudio/src$ ls
dogcontract.cpp  helloworld.cpp
ted@ted-VirtualBox:~/EOSStudio/src$ cd ..
ted@ted-VirtualBox:~/EOSStudio$ eosio-cpp -abigen -o dogcontract.wasm src/dogcontract.cpp
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <insert> does not have a ricardian contract
Warning, action <erase> does not have a ricardian contract
Warning, action <modify> does not have a ricardian contract
Warning, action <removeall> does not have a ricardian contract
1 Like

All looks good, at the end of the console, it said warning, action <actionName> ... which is a sign that the contract compile successfully, thats only a suggestion that your actions should also fulfill the ricardian contract requirements, but nothing to worry about.

In fact, every time you compile and you receive that suggestion, it means your contract is OK.

Carlos Z

1 Like

Was able to go a step further and get the dogcontract code to compile with the additional code with send_summary wtih the notify action, but the code in the video appears to be wrong. When it didn’t compile, I realized that instead of what Filip had there where he put owner as the first argument of send_summary, that doesn’t work for the erase, modify, or removeall functions because owner is not passed into the code. For erase and modify, I used dog.owner and for removeall, that wasn’t an option, so I used user.

But beyond that, I wasn’t able to start nodeos correctly because “database dirty flag set (likely due to unclean shutdown)” And if I add --hard-replay-blockchain to the start command, it says it doesn’t recognize the command.

Also, how do I shut down the database gracefully next time?

1 Like

Hey man, hope you are ok.

That error message shows up when you have not close properly the nodeos process. You interrupt it in the middle of the process so the database got corrupted.

I have solve this issue in the past and create a quick guide for it, you can check it here:

Carlos Z

1 Like

OK, next problem. I had the same problem with my default wallet as below, but here’s what I did when I created a new wallet called ted. At the account creation, it says I don’t have the proper keys or permissions.

ted@ted-VirtualBox:~/contracts$ cleos wallet open -n ted
Opened: ted

ted@ted-VirtualBox:~/contracts$ cleos create key --to-console
Private key: 5K2p2NNymTXktutmMfymekYHk594ZCKVEpDtuStW4dP7qE8ZRiw
Public key: EOS6BTBSifV3jtXo4TRrtSTMQJRdcMnsjZZuErc4wjDYRrB6r4LQY

ted@ted-VirtualBox:~/contracts$ cleos wallet unlock -n ted
password: Unlocked: ted

ted@ted-VirtualBox:~/contracts$ cleos wallet import -n ted
private key: imported private key for: EOS6BTBSifV3jtXo4TRrtSTMQJRdcMnsjZZuErc4wjDYRrB6r4LQY

ted@ted-VirtualBox:~/contracts$ cleos create account eosio ted EOS6BTBSifV3jtXo4TRrtSTMQJRdcMnsjZZuErc4wjDYRrB6r4LQY EOS6BTBSifV3jtXo4TRrtSTMQJRdcMnsjZZuErc4wjDYRrB6r4LQY
Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
Error Details:
transaction declares authority ‘${auth}’, but does not have signatures for it.

1 Like

You need to add the eosio accounts private key in order to be able to create accounts.

Import this priv key to your wallet.
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

Carlos Z

1 Like

Going back to compilation, I don’t see any .abi file being generated. I searched with the graphical file manager from the root and nothing came up. Remember, when I compile, it always locks up and the .wasm file is always .wasm.tmp.... and a few other characters. So I renamed it, but now that I see no .abi file, I’m wondering if it’s compiling correctly. Also, in cleos set contract ted /home/ted/EOSStudio ./helloworld.wasm --abi dogcontract.abi -p ted@active, why do we enter path ./file rather than just path/file which I noticed gets interpreted strangely and doesn’t work.

the dot . before the back slash means to look into the same folder as you are currently in the session, so if you are inside folder /home/ted/EOSStudio, instead of writing the same path for each file that exist into that folder, you use ./helloworld.wasm for example, to refer ‘In this same folder’.

Also, have you tried to update the nodeos version? might be that the SDK is not compatible with the syntax version.

Carlos Z

1 Like

The latest verified release is v2.0.8 at https://github.com/EOSIO/eos/releases. I did wget https://github.com/EOSIO/eos/releases/download/v2.0.8/eosio_2.0.8-1-ubuntu-18.04_amd64.deb and then sudo apt install ./eosio_2.0.8-1-ubuntu-18.04_amd64.deb but the results are the same. It still freezes at compile, creates extra characters after wasm.temp, and does not generate a .abi file.

1 Like

So might be a syntax error, try to delete some functions, remove them temporary, until it compile, then start adding the functions until all the contract compiles.

The idea is to know if one function is the one that is getting the compiler stuck.

Carlos Z

1 Like

I took out all of the actions and functions. Below is what’s left. Below that is the .wasm file which is a little different this time, but it froze again after a couple of empty ricardian warnings and no abi file was generated. Remember, before I added the code for the inline actions, I used Excel to verify that my code was absolutely identical to what you had in Github.

#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>

using namespace std;
using namespace eosio;

CONTRACT dogcontract : public contract {
public:
using contract::contract;
dogcontract(name receiver, name code, datastream<const char*> ds)
:contract(receiver, code, ds)
, currency_symbol(“DOGCOIN”, 0){}
/*
** Function insert the name and age of a dog with the dog_id.
** Owner can not be changed in this function.
*/

private:
  const symbol currency_symbol; //to check if payment match our currency symbol

    //table struct dog data
    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
        uint64_t primary_key() const{return id;}
        //get dogs by owner index
        uint64_t by_owner() const{return owner.value;}
    };//end table dog

    //table struct balance, used to manage account funds
    TABLE balance {
        asset funds; //asset is EOS type for tokens
        //primary key for table, never used but need it
        uint64_t primary_key() const{return funds.symbol.raw();}
    };//end table balance

    //define table type index
    typedef multi_index<"dogs"_n, dog, indexed_by<"byowner"_n, const_mem_fun<dog, uint64_t, &dog::by_owner>>> dog_index;
    //index for balance table
    typedef multi_index<"balances"_n, balance> balance_index;
};

Here is what’s in the .wasm file (after a bunch of these �):

.eosio_abi�{"____comment":“This file was generated with eosio-abigen. DO NOT EDIT “,“version”:“eosio::abi/1.1”,“structs”:[{“name”:“balance”,“base”:””,“fields”:[{“name”:“funds”,“type”:“asset”}]},{“name”:“dog”,“base”:"",“fields”:[{“name”:“id”,“type”:“int32”},{“name”:“dog_name”,“type”:“string”},{“name”:“age”,“type”:“int32”},{“name”:“owner”,“type”:“name”}]}],“types”:[],“actions”:[],“tables”:[{“name”:“balances”,“type”:“balance”,“index_type”:“i64”,“key_names”:[],“key_types”:[]},{“name”:“dogs”,“type”:“dog”,“index_type”:“i64”,“key_names”:[],“key_types”:[]}],“ricardian_clauses”:[],“variants”:[],“abi_extensions”:[]}

I forgot to mention, when I start EOS, I see this item at the bottom. Seems like it might be necessary, but I want to be sure. EOS programs

1 Like

Yes, it is completely necessary, might the why your contract is failing at compiling, cuz the eosio compiler will find which system contracts refer to keywords on your contract.

Install it try to run your contract again.

Carlos Z

1 Like

Unfortunately, I got identical results after installing.

1 Like

Ok, but which contract are you trying to compile? the helloworld or my dog contract?

also which command are you using at compilation?

Carlos Z

Dog contract only. Here’s the line:
eosio-cpp -abigen -o dogcontract.wasm src/dogcontract.cpp

What do you think @thecil?

1 Like

Hey man, sorry for the late reply!!

Now, try to do the following:
Create a new ‘helloworld’ project (delete any existent), it will create a helloworld contract, try to compile and deploy that one.

In case you face the same error, i think it could be the docker…

Carlos Z

1 Like