Payable Keyword in Solidity

Use Payable as Keyword, not function name

First, payable is a modifier that can be added to a function. It's impossible to have payable() as a function name as it is a reserved keyword. You may use payable only in addition to existing functions like:

Receive Ether from Call Transactions

Second, Payable allows a function to receive ether while being called as stated in docs.It's manadatory from solidity 0.4.x. If you try to send ether using call:

to a function without a payable modifier, the transaction will be rejected.

Usually, there is a no name function to accept ether to be sent to a contract which is called a fallback function:

But you may have more than one payable annotated functions that are used to perform a different tasks.

Example: How to register deposit to your contract:




Blockchain | Data Science | Cosmonaut

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store