#6 Payable Functions in Solidity — Smartcontract — Ethereum

Payable functions provide a mechanism to collect / receive funds in ethers to your contract . Payable functions are annotated with payable keyword.

In the above example payme function is annotated with payable keyword, which translates to that you can send ethers to payme function.

Where are the ethers stored in payable functions?

All the ethers sent to payable functions are owned by contract. In the above example Sample contract owns all of the ethers.

Payable fallback functions :

A function without any name and annotated with payable keyword is called payable fallback function. There could be only one such function in contract.

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