Earn While Learning Web3 Programming>> Start Here FREE!!!
EXERCISE:
i. Summarize your understanding of What Is Payable function in solidity
(NOTE: please, don't go and copy paste from other students in the forum, try things on your own, so you can master it yourself)
NOTE:
This Is An Exercise From Our FREE Smart Contract Development With Solidity For Beginners Course (If you have not enrolled yet, you can join the course totally for FREE).
Functions in Solidity By Payment Capability are:
1) Payable Deposit/Receive Funds Capability
This allows smart contract to receive deposit of native cryptocurrency of the blockchain on which it is deployed and must be denoted with the keyword payable in the function header from Solidity 0.8.0 version and above.
REMINDER: Native coin differs from one EVM Blockchains to another.
For example, it is ETH on Ethereum Blockchain, BNB on Binance Smart Chain (BSC), MATIC on Polygon, AVAX on Avalanche, FTM on Fantom Blockchain and a lot more.
Payable deposit function is written in solidity as:
//example of payable functions use to receive Ether on Ethereum Blockchain Smart Contract
function addFund() public payable {
}
2) Payable Transfer/Withdraw Funds Capability
Deposit function allow for people to be able to make a deposit on the smart contract.
And payable function only allow an address owner to withdraw from only his own deposit.
![Solomon Foskaay Solomon Foskaay](http://dprogramminguniversity.com/wp-content/uploads/wpforo/avatars/foskaay_1.jpg)
@leouloko Kindly note that PAYABLE FUNCTION is divided into :
(1) Deposit
(2) Withdraw/transfer
Both ensure your Smart contract can accept payment and also allow withdrawal of the received payment.
Without payable function, even if the fall-back function still help your smart contract to accept payment/deposit.
The money will be permanently stuck in it and won't be able to withdraw it out because it does not include Payable withdraw/transfer function from the Smart contract to normal wallet.