A contract in Solidity can have a special function called the fallback function.
This function is called when you directly send Ether to the contract or call a non-existing function inside the contract. In this video, I will show you how the fallback funciton is executed when you send Ether to the contract via transfer and call methods.
Code: https://solidity-by-example.org/fallback/
Remix IDE: http://remix.ethereum.org
Solidity: https://solidity.readthedocs.io
Follow on Twitter: @ProgrammerSmart https://twitter.com/ProgrammerSmart
Website: https://smartcontractprogrammer.com