eos icon indicating copy to clipboard operation
eos copied to clipboard

mycontract need to modify another contract data on user scope, mycontract must has the user signature,but mycontract will never has user signature by push action?

Open chenlian2015 opened this issue 8 years ago • 1 comments

mycontract need push action to currency contract(DAWN-2018-03-30-ALPHA) to auto transfer balance

my contract code mycontract.cpp:

void send_deferred_transaction() {
   using namespace eosio;
   auto trx = transaction();
   transfer trans = unpack_action_data<transfer>();
   test_action_action<N(currency), N(transfer)> transfercurrency;
   copy_data((char*)&trans, sizeof(trans), transfercurrency.data);
   trx.actions.emplace_back(vector<permission_level>{{trans.from, N(active)}}, transfercurrency);
   trx.send( 0xffffffffffffffff, now()+2 );
}

after mycontract published,run my command: cleos push action mycontract transfer '{"from":"oct", "to":"chenlian", "quantity":"10 CUR", "memo":""}' -p oct@owner

then get Error 3030002: signatures do not satisfy declared authorizations Ensure that you have the related private keys inside your wallet and you wallet is unlocked

then, i modify mycontract.cpp code as below:

void send_deferred_transaction() {
   using namespace eosio;
   auto trx = transaction();
   transfer trans = unpack_action_data<transfer>();
   test_action_action<N(currency), N(transfer)> transfercurrency;
   copy_data((char*)&trans, sizeof(trans), transfercurrency.data);
   trx.actions.emplace_back(vector<permission_level>{{N(mycontract), N(active)}}, transfercurrency);
   trx.send( 0xffffffffffffffff, now()+2 );
}

after mycontract published,run my command: cleos push action mycontract transfer '{"from":"oct", "to":"chenlian", "quantity":"10 CUR", "memo":""}' -p oct@owner

then i get error as below:

 3171506ms thread-0   chain_controller.cpp:1619     log_handled_exceptio ] 3030001 tx_missing_auth: missing required authority
missing authority of chenlian
    {"account":"chenlian"}
    thread-0  apply_context.cpp:122 require_authorization

    {"_pending_console_output.str()":""}
    thread-0  apply_context.cpp:29 exec_one

    {}
    thread-0  chain_controller.cpp:1662 __apply_transaction

summary:mycontract need to modify another contract data on user scope, mycontract must has the user signature,but mycontract will never has user signature by push action?

chenlian2015 avatar Apr 04 '18 03:04 chenlian2015

oct first not authorize [email protected] with his active permission beforehand. Please refer to the first comment here https://github.com/EOSIO/eos/issues/4326

The above transaction API is already outdated by the way. Please try again with the latest code and new API and if you still encounter a similar problem, please open new issue, I'm closing this issue. Thanks!

andriantolie avatar Jul 03 '18 10:07 andriantolie