eos icon indicating copy to clipboard operation
eos copied to clipboard

inline action recursion

Open vtornik23 opened this issue 8 years ago • 8 comments

Hi all! I'm trying to make a function to sell an nft item in my game. Item belongs to user, who transferred it to my contract Another user should buy it. So buyer sends some money to contract -> contract should transfer Item to buyer AND transfer money to the seller. And everything works fine but: if i do all the logic in one method i'm getting error Error 3040000 inline action recursion depth reached

Here is the piece of my method:

void mygame::transfer(from, to, price, memo)
{
...
// send nft to buyer
action(permission_level{ _self, N(active) },
               N(mygameeos), N(nfttransfer),
               std::make_tuple(_self, from, id, memo)
        ).send();
// send money to seller
action(permission_level{_self, N(active) },
               N(eosio.token), N(transfer),
			   std::make_tuple(_self, from, sendprice, memo)
        ).send();
}

What i do wrong?

vtornik23 avatar Sep 12 '18 21:09 vtornik23

What is the value in your genesis.json file for "max_inline_action_depth"? Are these the only inline actions (either regular inline actions or context free inline actions) you have in this entire transaction? (The error wording is wrong, it should be "inline action depth reached", "recursive" is wrong.)

brianjohnson5972 avatar Sep 12 '18 23:09 brianjohnson5972

(@vtornik23 Note that I updated the text in my original response. I am not certain if github sends a subsequent email with the correction.)

brianjohnson5972 avatar Sep 12 '18 23:09 brianjohnson5972

Does your code mygameeos::nfttransfer also use inline actions? or mygame::transfer is triggered by some inline action?

taokayan avatar Sep 13 '18 02:09 taokayan

Closed because of no reply. If you still have the problem and wish to discuss further, please post it in https://eosio.stackexchange.com.

taokayan avatar Nov 05 '18 06:11 taokayan

What was the solution? I am getting this same error: https://eosio.stackexchange.com/questions/3801/max-inline-action-depth-per-transaction-reached-on-simple-eos-transfer-action-ca

johnworthley avatar Jan 27 '19 00:01 johnworthley

Both the sender and receiver of a token transfer are notified of that transfer. The code in that handler isn't checking to see if your contract is the sender or receiver of the tokens, so, I suspect when you send the inline action you are getting notified of it as the sender of tokens which then triggers another inline transfer and creates an infinite loop.

On Sat, Jan 26, 2019, 7:41 PM johnworthley <[email protected] wrote:

What was the solution? I am getting this same error: https://eosio.stackexchange.com/questions/3801/max-inline-action-depth-per-transaction-reached-on-simple-eos-transfer-action-ca

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/EOSIO/eos/issues/5632#issuecomment-457878852, or mute the thread https://github.com/notifications/unsubscribe-auth/ACYR4ihzqaZvWuNBZFJQEPixWckI63TSks5vHPXQgaJpZM4WmNql .

wanderingbort avatar Jan 27 '19 00:01 wanderingbort

Using if (latestRecord.account.name != _self)) before the inline transfer did the trick!

johnworthley avatar Jan 27 '19 01:01 johnworthley

also got this error occasionally, how to calculate the inline actions depth, how many actions depth as case below? 3 or 4?

->A
   ->B
   ->C
      ->D

anyway to dump the actions before this error occurs?

crazybits avatar Sep 01 '21 15:09 crazybits