3

I'm getting this error: "Error 3090004: Missing required authority" when I try to call contract method. Jungle testnet is used.

That is the method:

      //@abi action
      void add(account_name name, uint64_t owner) {
           ordertable orders(_self, _self);
           orders.emplace(owner, [&](auto& order) {
                order.owner = owner;
           });
       }

Contract is compiled and deployed. I'm using that:

cleos  -u https://jungle.eosio.cr:443  set contract myaccount  ./ ./order.wast ./order.abi

And contract is called with that:

cleos -u https://jungle.eosio.cr:443 push action myaccount add '["myaccount","2"]' -p myaccount@active

Any ideas what might be wrong?

  • first argument to emplace is the payer, while in your case is just number 2. try _self or name instead of owner as the first argument – confused00 Aug 7 '18 at 11:54
  • @confused00, it works! Thank you man! – iobeta123 Aug 7 '18 at 11:57
3

The problem is that the first argument passed to the emplace() method in the multi-index structure is not an account you have permission to use as a payer.

According to the docs, the parameters are as follows:

Parameters

  • payer - Account name of the payer for the Storage usage of the new object

  • constructor - Lambda function that does an in-place initialization of the object to be created in the table

Thus, the first parameter should be the account_name of the account that's expected to pay, while in your example you pass the uint64_t 2.

You can use name if you want the account calling the function to pay for RAM to store the new row, or you can use _self if you want the smart contract creator to pay for the RAM usage.

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.