0

I need to write a simple function that would send tokens using a different account action. Exactly the same situation as in these questions: one and two

But I have to use not eosio.token contract but my custom contract < transfercontract > that is similar to eosio.token.

My transfer code for < maincontract > looks like:

std::vector<permission_level> p;
p.push_back(permission_level{from, "active"_n});
action(p, "<transfercontract>"_n, "transfer"_n, std::make_tuple(from, to, quantity, std::string("Deduction test"))).send();

I used the command for adding eosio.code to the active permissions like here:

cleos set account permission <maincontract> active '{"threshold" : 1, "keys" : [{"key": "EOSpublicKey", "weight": 1}], "accounts" : [{"permission":{"actor":"<maincontract>","permission":"eosio.code"},"weight":1}], "waits":[]}}' owner -p <maincontract>@owner

After that, I used my < maincontract > action with the following permissions:

cleos push action <maincontract> actionname '["from","to", "quantity"]' -p from

Actually, I've tried several different options for permissions, but nothing worked.

Please, help me resolve it.

I did not set the permissions correctly when performing a transaction? or incorrectly added additional permissions for the account?

UPDATE:

The execution:

cleos push action crowdfledger customaction '["forbanpirate","anotheraccount","1.000 TKN"]' -p forbanpirate

The crowdfledger contract tries to use <transferaccount >::transfer(forbanpirate, anotheraccount, 1.0000 TKN) inside.

The error:

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

pending console output:

  • Provide the exactly error message you're experiencing and... cleos push action <maincontract> actionname '["from","to", "quantity"]' -p from should they have a memo included in parameters? – John Williamson Jun 18 at 3:17
  • I've added the error into the post. No, the memo is hardcoded, so there is no need to send it. @JohnWilliamson – Dmitry Kryukov Jun 18 at 3:29
  • Add the private key of your account on which your token smart contract is deployed into you wallet. – Ridham CPP Jun 18 at 13:12
  • @RidhamCPP All required private keys are imported into the wallet. – Dmitry Kryukov Jun 18 at 13:58
0

I'm having a similar issue, basically inline transactions cannot use the active key on the users behalf, but there are work arounds to getting the functionality done.

One such method is to have the user add a permission to the contract code to act on their behalf. Another is to use listeners for say a transfer and only act if the transfer meets a certain requirement, such as a transfer to the contract with a memo of "do this action". There are probably other methods as well.

see more here: Require inline action be sent by contract, and not account

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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