1

I have got contract code below:

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

using namespace std;
using namespace eosio;

class deneme: contract {
   // @abi table  
   struct countries {
      name sender;
      string country;

      name primary_key() const { return sender; }
      EOSLIB_SERIALIZE( countries, (sender)(country) )
   };
public:
   deneme(account_name self):
    contract(self),
    _countries(_self, _self) {}

   multi_index< N(countries), countries > _countries;

  // @abi action
  void myaction(name sender,string country) {
    // add to table, first argument is account to bill for storage
     _countries.emplace(sender, [&](auto& row) {
        row.sender = sender;
        row.country = country;
     });
  }
};
EOSIO_ABI( deneme, (myaction) )

And generate wast and abi file with:

eosiocpp -o deneme.wast deneme.cpp
eosiocpp -g deneme.abi deneme.cpp

Deploy contract with (there was no change on nodeos terminal when setting contract):

cleos set contract eosio ../deneme -p eosio

Finally I try to push action like :

cleos push action deneme myaction '{"sender":"eosio","country":"anywhere"}' -p eosio

I've got an error below :

Error 3060004: Contract Query Exception
Most likely, the given contract doesnt' exist in the blockchain.

nodeos says:

162072ms thread-0   http_plugin.cpp:405           handle_exception]
FC   Exception encountered while processing chain.abi_json_to_bin
162072ms thread-0   http_plugin.cpp:406           handle_exception]
Exception Details: 3060004 contract_query_exception: Contract Query  
Exception
Contract can't be found deneme
{"contract":"deneme"}threadchain_plugin.cpp:1103   abi_json_to_bin{"params.code":"deneme","params.action":"myaction","params.args
{"sender":"eosio","country":"istanbul"}}thread-0  chain_plugin.cpp:1119 abi_json_to_bin

Also when I set contract nodeos says nothing (no changes on nodeos terminal). Where am I doing wrong?

  • if you do want set the contract on eosio, you need push action to that account " cleos push action eosio myaction '{"sender":"eosio","country":"anywhere"}' -p eosio " – Reason Lee Jan 23 '19 at 2:28
2

You need to set the contract to your deneme account not to eosio.

For local development you have to do the following (considering you already have a wallet and unlocked it).

Create two key pairs for active and owner

cleos create key

Output:

Private key: <private_key_1>

Public key: EOS....xyz

run it twice and write down the key pairs

Now import them to your wallet

cleos wallet import <private_key_1> -n <wallet_name> 

Import the eosio private key for account creation:

cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -n <wallet_name> 

Then you need to create your account deneme

cleos create account eosio deneme <owner_public_key> <active_public_key> 

Deploy to deneme account

cleos set contract deneme <path_to_contract> <path_to_contract>/deneme.wast <path_to_contract>/deneme.abi -p deneme

Test an action

cleos push action deneme myaction '{"sender":"eosio","country":"anywhere"}' -p denem@active
|improve this answer|||||
  • you can also use "cleos wallet create_key", so there is no need to import the key – Reason Lee Jan 23 '19 at 2:26
0

cleos set contract eosio, should not be eosio, but deneme, and you must create an account for deneme

|improve this answer|||||

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.