This question already has an answer here:

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

How do I declare a fallback function in my contract ?

marked as duplicate by Ismael, Achala Dissanayake, Richard Horrocks, mirg, mafrasi2 May 28 '18 at 4:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @Ismael it doesn’t describe how to declare such function but explain what it does. – user2284570 May 27 '18 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 { }". – Richard Horrocks May 27 '18 at 20:45
  • Documentation is here: solidity.readthedocs.io/en/latest/… – Richard Horrocks May 27 '18 at 20:47

Is easy.

function () payable public{

Hope it helps

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

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