I have a smart contract with a payable bet() function. When someone sends 1 ether to the bet function, the contract is executed.
I'd like the contract to run the same code when someone sends ether to the address explicitely (as if you're sending ether to someone else), without having to use the function bet().
How do I do this?
Thanks
Best Answer
you need to use the Fallback function like in the code below. this function is executed when someone send Ethers to the contract without providing any data or calling a function :
this function don't accept any parameters, you need when using this fallback to check your security model to avoid any problems.