msg.value
Solidityपरिभाषा
msg.value एक global variable है जो current transaction के साथ भेजे गए ether की amount (wei में) को represent करता है। यह केवल payable functions में available है। msg.value को payments accept करने और deposit tracking के लिए use किया जाता है।
English version
msg.value is a global variable that represents the amount of ether (in wei) sent with the current transaction. It is only available in payable functions. msg.value is used to accept payments and track deposits.
Code Example
function deposit() public payable {
require(msg.value >= 0.1 ether, "Minimum 0.1 ETH");
balances[msg.sender] += msg.value;
}
function buyTokens() public payable {
uint256 tokens = msg.value * 100; // 1 ETH = 100 tokens
_mint(msg.sender, tokens);
}संबंधित शब्द
संबंधित पेज
Solingo पर इस concept को practice करें
msg.value को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें