When declaring fallback function we needs to make sure that it is declared external but why fallback function cannot be declared as public. Since external is a subset of public why can't we declare the fallback function public.

Viewing from the perspective of definition of external(Only accessible externally not internally). Why do use external in fallback?

  • Because there is obviously no reason to call it internally. Jul 11, 2020 at 13:23
  • @goodvibration why not public? Jul 11, 2020 at 13:23
  • Because there is obviously no reason to call it internally (let me know if you want me to repeat that again). Jul 11, 2020 at 13:23
  • @goodvibration my bad. Understand it now Jul 11, 2020 at 13:27
  • The answer below explains it quite well (why there is obviously no reason to call it internally). You may wanna read it. Jul 11, 2020 at 13:28

1 Answer 1


From the Solidity documentation:

A contract can have at most one fallback function, declared using fallback () external [payable] (without the function keyword). This function cannot have arguments, cannot return anything and must have external visibility. It is executed on a call to the contract if none of the other functions match the given function signature, or if no data was supplied at all and there is no receive Ether function. The fallback function always receives data, but in order to also receive Ether it must be marked payable.

There's no real purpose for calling it internally, since it cannot have any arguments and cannot return anything. For that reason, it must be declared as external.

  • Thanks for your answer bro. Jul 11, 2020 at 13:30

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.