Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Authorization problem when calling ”eosio.token::transfer“ action in another contract #498

Open
dwjpeng opened this issue Jun 17, 2020 · 1 comment

Comments

@dwjpeng
Copy link

dwjpeng commented Jun 17, 2020

I called eosio::token transfer action in contractA's method "method1" as rex's deposit action like this:

image

but why I encountered this error as follows, it seems checking authorizaions cannot find provided_permissions and provided_keys.

cleos push action user1 method1 ‘[“user1”,”user2","1.00000000 TBC”,”send TBC”]’ -p 
 user1@active                                                                                                    

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 '${auth}', but does not have signatures for it under a provided 
delay of 0 ms, provided permissions ${provided_permissions}, provided keys 
${provided_keys}, and a delay max limit of 3888000000 ms

my code:

  #include <eosio.system/eosio.system.hpp>
  #include <eosio.token/eosio.token.hpp>

 using eosio::token;
 using eosiosystem::system_contract;

 void contractA::method1(const name &from,
                const name &to,
                const asset &quantity,
                const string &memo) {

   check(from != to, "cannot transfer to self");
   require_auth(from);
   check(is_account(to), "to account does not exist");
   auto sym = quantity.symbol.code();

   symbol fee_sym = st.supply.symbol;
   int64_t amount = st.fee;

   asset fee = asset(amount, fee_sym);

   auto payer = has_auth(to) ? to : from;

   token::transfer_action transfer_act{
         system_contract::token_account,
         { payer, system_contract::active_permission }
    };
    transfer_act.send( payer, to, fee, "fee");
}
@deckb
Copy link
Contributor

deckb commented Apr 19, 2021

Is this still an issue for you? I believe this is failing because you do not have the permission eosio@code added to the contract account.

https://developers.eos.io/welcome/latest/smart-contract-guides/adding-inline-actions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants