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 _self
inside.
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:
_self
is not recognized ad does not compile;N(_self)
gives the error: "Error 3050000: Action validate exception; inline action's authorizing actor .self does not exist";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.
function2
body:permission_level{user, N(active)},
require_auth(get_self());
in the contract , have you given hardcoded contract name or likeget_self()
.mycontract
with actormycontract
that is strange. It mean you set your contract withmycontract
. so while calling action in your account you should use` N(mycontract)` instead ofN(othercontr)
.