Solidity Output Prediction Hard +35 XP
view vs pure
What is the difference between view and pure functions?
SolidityRead-only
function getBalance() public view returns(uint) { return balance; }
function add(uint a, uint b) public pure returns(uint) { return a+b; }What is the output?
Show answer and explanation
Answer: view reads state, pure doesn't read or modify state
view promises not to modify state but can read it. pure promises not to read OR modify state.
Hint: pure is stricter — no state interaction at all.
What this challenge tests
Output Prediction in Solidity: view, pure, gas.