2

In a contract action I've got the following:

require_auth(from);  // NOTICE THIS LINE...
INLINE_ACTION_SENDER(contract, transfer)(
    N(contract),
    {from, N(active)},  // ... AND THIS LINE.
    {from, to, price, memo});

When I invoke the action I get:

Error 3030002: signatures 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":"myaccount","permission":"active"}', but does not have signatures for it.

Notice that require_auth(from) passes but the inline action fails because the authorization {from, N(active)} is not present.

How is that possible? Doesn't require_auth(from) in effect check for the authorization {from, N(active)}?

Methodology

I'm invoking the action as follows:

cleos push action contract action \
  '[ myaccount theiraccount "16 BTC" "DD => PP (C=8)" ]' -p myaccount@active

-p myaccount@active explicitly provides myaccount@active authorization, a fact that I can verify by running, for example, the following...

cleos push action contract action \
  '[ myaccount theiraccount "16 BTC" "DD => PP (C=8)" ]' -p essential@active

...which causes the require_auth(from) to fail as expected...

Error 3030001: 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.
Error Details:
missing authority of myaccount

...because I didn't provide -p myaccount@active.

1 Answer 1

2

From an answer by Todd Fleming on the EOS Developers Telegram channel:

If user A authorizes an action sent to contract B then that does not imply B can send an action to contract C with A's authorization.

There are two ways to address this. The bad way: have users authorize B to act on their behalf. The good way: contracts can detect when someone transfers tokens to them and act on it.

3
  • I'm not thrilled with this answer because AFAIK the "good" way does not cause the actions to execute as an atomic transaction.
    – kkurian
    Commented May 18, 2018 at 7:16
  • This make sense since B would act as a middleman in "the bad way". I see a contract can send a transaction with action.send() . Are there any examples on how to "detect" a transfer to a contract? Commented May 18, 2018 at 23:42
  • @MagicManXpress You mean like this? eosio.stackexchange.com/questions/364/…
    – kkurian
    Commented May 21, 2018 at 18:08

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.