Re-entrancy mainly occurs when one contract calls the fallback function of another contract and it again invoke the same caller function and it keeps on doing this. This is pretty much clear. But can we have a scenario where we can have some re-entrancy type thing without fallback function also?

For example, we have two contracts A and B. So question is can we make above thing happen here. A calls B and B calls A. Also, can we extend is approach to multiple contracts i.e. can we make a GENERIC SMART CONTRACT scenario where RE-ENTRANCY CODE work for any number of smart contracts not just A and just B. but condition is that there should be no fallback function.

  • 1
    Yes. It doesn't matter what function is called. Did you run into some specific trouble when trying to do this?
    – user19510
    Mar 19 '18 at 17:31
  • Thanks @smarx. and yeah I get that it doesn't matters which function I call as far as I am able to create a loop between contracts. For the first question that I have asked - answer is YES, there can re-entrancy without fallback but I guess this is the scenario when both contracts know about each other because eventually one has to call each other's function. Now, can a third contract say C would be able to create a loop with the given two contracts A or B which doesn't have any idea about C and this is the main question. Thanks in advance. Mar 20 '18 at 4:01
  • 1
    A and B will do whatever they're programmed to do. So the question is sort of meaningless in general... you'd have to look at specific contracts to figure out if they could be involved in reentrancy. Given that reentrancy is often considered a security bug, a well-written A will usually not allow reentrancy.
    – user19510
    Mar 20 '18 at 4:07

Your Answer

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

Browse other questions tagged or ask your own question.