0

There is a contract B with an action 'create' which uses require_auth( get_self() ). I would like to call that action from another contract A, is that even possible and if so - how?

Contract b has

CONTRACT B : public contract
{
   ACTION create() {
      require_auth( get_self() );
      printf("Hello");
   }
}

A noin-working implementation that channels the B account does not work

CONTRACT A : public contract
{
   ACTION do() {
     action (
         permission_level { "B"_n, "active"_n },
         "B"_n,
         "create"_n,
         std::make_tuple (
            ...
         )
     ).send();
   }
}

cleos

cleos push action A do '{}' -p B@active

Both A@active and B@active have eosio.code permission

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 '{"actor":"B","permission":"active"}', but does not have signatures for it under a provided delay of 0 ms, provided permissions [{"actor":"A","permission":"eosio.code"}], provided keys [], and a delay max limit of

1 Answer 1

1

Any inline action from contract A is executed with [email protected] permission. require_auth(get_self()) in contract B means it should be executed with B@active permission.

Your case can be resolved by adding [email protected] to B@active, but it means that inline actions from contract A can trigger any other actions with B@active permission. Unless you own both contract A and B, you shouldn't do that.

If [email protected] is added to A@active, you can check permission like:

eosio::check(has_auth(get_self()) || has_auth("A"_n), "missing required authority");

Your Answer

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

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