Recall & Review
beginner
What is a view function in blockchain smart contracts?
A view function is a type of function that reads data from the blockchain but does not modify the state. It does not cost gas to call because it does not change anything.
Click to reveal answer
beginner
What does a pure function mean in blockchain smart contracts?
A pure function neither reads nor modifies the blockchain state. It only uses its input parameters to compute and return a result, without any side effects.
Click to reveal answer
intermediate
Why do view and pure functions not cost gas when called externally?
Because they do not change the blockchain state, the network does not need to record any changes, so calling them is free and does not consume gas.
Click to reveal answer
beginner
Can a view function modify the blockchain state?
No, a view function is not allowed to modify the blockchain state. It can only read data.
Click to reveal answer
intermediate
Give an example of when to use a pure function in a smart contract.
Use a pure function when you want to perform calculations or return a value based only on the input parameters, like adding two numbers, without reading or changing any stored data.
Click to reveal answer
Which of the following best describes a view function?
✗ Incorrect
A view function can read blockchain data but cannot modify it.
What is true about pure functions in smart contracts?
✗ Incorrect
Pure functions do not read or modify blockchain state; they only use inputs to compute outputs.
Why do view and pure functions not consume gas when called externally?
✗ Incorrect
They do not consume gas because they do not change the blockchain state.
Which function type can perform calculations without accessing blockchain data?
✗ Incorrect
Pure functions perform calculations using only input parameters without accessing blockchain data.
Can a view function call a pure function?
✗ Incorrect
View functions can call pure functions since pure functions do not modify state.
Explain the difference between view and pure functions in blockchain smart contracts.
Think about what each function can read or change on the blockchain.
You got /4 concepts.
Describe why calling view or pure functions externally does not cost gas.
Consider what causes gas fees in blockchain transactions.
You got /4 concepts.