Payable Keyword in Solidity

Use Payable as Keyword, not function name

Dec 26, 2017 · Unlisted

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:

function deposit() payable {};
function register(address sender) payable {};
function () payable {}

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:"ETH_TO_BE_SENT")("ADDITIONAL_DATA")

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:

function () payable {};

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:

function deposit() payable {
deposits[msg.sender] += msg.value;


Sophie Huang

Written by

Blockchain | Data Science | Cosmonaut

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade