2

I need help for an issue developing an EOS dapp. I want to call a contract function when someone transfer EOS to my contract. For this i used the apply method to call the function upon any transfer to my contract. This contract works fine on Local chain but getting error on testnet.

Here is the error that we get :

Error 3100006: Subjective exception thrown during block production
Error Details:
Cannot charge RAM to other accounts during notify.

Below is the code of apply function:

#undef EOSIO_ABI
#define EOSIO_ABI( TYPE, MEMBERS ) 
extern "C" { 
void apply( uint64_t receiver, uint64_t code, uint64_t action ) { 
      auto self = receiver; 
      if( action == N(onerror)) { 
         /* onerror is only valid if it is for the "eosio" code account and authorized by "eosio"'s "active permission */ 
         eosio_assert(code == N(eosio), "onerror action's are only valid from the \"eosio\" system account"); 
      } 
    print( "receiver, ", name{receiver} );
    print( "code, ", name{code} );
    print( "action, ", name{action} );
    TYPE thiscontract( self ); 
      if(code == N(eosio.token) && action == N(transfer) ) { 
    thiscontract.buy(unpack_action_data<eosio::currency::transfer>());
         switch( action ) { 
                break;
            EOSIO_API( TYPE, MEMBERS ) 
         } 
         /* does not allow destructor of thiscontract to run: eosio_exit(0); */ 
      } 
   } 
} 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.