3

WHAT I WANT

From the contract mycontract I want to call a function function1. The function function1 calls another function of mycontract called function2. The function function2 calls an action of another contract othercontr. Both function1 and function2 use _selfinside.

user --> function1(...) --> function2(_self, ...)-->action[of othercontract]

WHAT IS WORKING

If I call directly function2(_self, ...), the function receives correctly _self and works fine.

WHAT IS NOT WORKING

I tried the following options as function2 arguments:

  1. _self is not recognized ad does not compile;
  2. N(_self) gives the error: "Error 3050000: Action validate exception; inline action's authorizing actor .self does not exist";
  3. N(mycontract) gives the error in the section ERROR.

CRIME SCENE

checksum256 result = function1(paramA, paramB);

checksum256 function1(uint8_t paramA, uint8_t paramB) {
    ...
    // Option 1. function2(_self, paramC, paramD);        
    // Option 2. function2(N(_self), paramC, paramD);
    // Option 3.
    function2(N(mycontract), paramC, paramD);
    ...
}

checksum256 function2(account_name user, uint8_t paramC, uint8_t paramD) {
    ... 
    // Calling the action "actionname" of the contract "mycontract".
    // The action "actionname" saves in a table the param "user", which is the action caller.   
    action(
      permission_level{user, N(active)},
      N(othercontr), N(actionname),
      std::make_tuple(user, paramC, paramD)
    ).send();
    ...
}

ERROR

Error 3090004: Missing required authority Ensure that you have the related authority inside your transaction!; If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.

10
  • when you calling the action whose permission are you providing at that time .? Oct 16, 2018 at 11:04
  • As written in the code, the permission is provided inside the function2 body: permission_level{user, N(active)}, Oct 16, 2018 at 11:08
  • I mean when you call the action using cleos. Oct 16, 2018 at 11:21
  • 1
    Can we have a look at require_auth(get_self()); in the contract , have you given hardcoded contract name or like get_self(). Oct 16, 2018 at 12:32
  • 1
    you are setting permission of mycontract with actor mycontract that is strange. It mean you set your contract with mycontract. so while calling action in your account you should use` N(mycontract)` instead of N(othercontr). Oct 16, 2018 at 12:58

1 Answer 1

1

The issue was inside an emplace().

Basically, I was not setting the payer. After, hard coding the payer as N(mycontract), I don't get the error anymore and the functions work correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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