0

Simple question but I couldn’t find the answer in the documentation.

How do I declare a fallback function in my contract ?

3
  • @Ismael it doesn’t describe how to declare such function but explain what it does. Commented May 27, 2018 at 19:52
  • The top (only) answer states, with reference to the relevant documentation: "If the contract is meant to receive Ether with simple transfers, you should implement the fallback function as: function() payable { }". Commented May 27, 2018 at 20:45
  • Documentation is here: solidity.readthedocs.io/en/latest/… Commented May 27, 2018 at 20:47

1 Answer 1

0

Is easy.

function () payable public{
}

Hope it helps

2
  • so it's about using thepayablekeyword, isn’t it ? Commented May 27, 2018 at 17:02
  • The payable keyword allows the function to receive ether.
    – Jaime
    Commented May 27, 2018 at 17:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.