Skip to main content
Solidity Output Prediction Hard +35 XP

msg.value Usage

What does msg.value contain in a payable function?

SolidityRead-only
function deposit() external payable {
  balances[msg.sender] += msg.value;
}

What is the output?

Show answer and explanation

Answer: Amount of ETH sent in wei

msg.value holds the amount of Ether sent with the transaction, denominated in wei (1 ETH = 1e18 wei).

Hint: msg.value is always in the smallest unit.

What this challenge tests

Output Prediction in Solidity: payable, ether.

Related challenges