eosio.contracts
eosio.contracts copied to clipboard
Authorization problem when calling ”eosio.token::transfer“ action in another contract
I called eosio::token transfer action in contractA's method "method1" as rex's deposit action like this:

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");
}
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