Payable
Solidityपरिभाषा
Payable modifier functions और addresses को ether receive करने की अनुमति देता है। बिना payable के, function ether नहीं accept कर सकता। Payable addresses में .transfer() और .send() methods होते हैं ether भेजने के लिए।
English version
The payable modifier allows functions and addresses to receive ether. Without payable, a function cannot accept ether. Payable addresses have .transfer() and .send() methods to send ether.
Code Example
// Fonction payable
function deposit() public payable {
balances[msg.sender] += msg.value;
}
// Address payable
address payable public recipient;
function withdraw() public {
uint256 amount = balances[msg.sender];
balances[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}संबंधित पेज
Solingo पर इस concept को practice करें
Payable को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें