Share:
Notifications
Clear all

Earn While Learning Web3 Programming>> Start Here FREE!!!

[Solved] Solidity Functions By Payment Capability - Payable Function

3 Posts
2 Users
2 Reactions
712 Views
1
Topic starter

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).

 

2 Answers
1
Topic starter

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

 

0

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 Topic starter 01/12/2021 9:06 am

@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.

Share: