Recall & Review
beginner
What is a state variable in blockchain smart contracts?
A state variable is a variable whose value is permanently stored on the blockchain. It keeps data between function calls and transactions.
Click to reveal answer
beginner
Where are state variables stored in a blockchain smart contract?
State variables are stored in the contract's storage on the blockchain, making their values persistent and shared across all users.
Click to reveal answer
beginner
How do state variables differ from local variables in smart contracts?
State variables are stored permanently on the blockchain, while local variables exist only temporarily during function execution and are not saved.
Click to reveal answer
intermediate
Why should you be careful when updating state variables in smart contracts?
Updating state variables costs gas (transaction fees) because it changes blockchain storage. Minimizing updates saves cost and improves efficiency.
Click to reveal answer
beginner
Give an example of declaring a state variable in Solidity.
Example:
uint public count;This declares a state variable named
count of type unsigned integer, stored on the blockchain.Click to reveal answer
What happens to a state variable's value after a smart contract function finishes execution?
✗ Incorrect
State variables keep their values permanently on the blockchain after function execution.
Which of these variables is stored temporarily during function execution?
✗ Incorrect
Local variables exist only during function execution and are not saved on the blockchain.
Why does updating a state variable cost gas in Ethereum?
✗ Incorrect
Changing state variables modifies blockchain storage, which requires gas fees.
Which keyword is used to declare a state variable in Solidity?
✗ Incorrect
The visibility keyword like
public is used with the type to declare a state variable accessible outside the contract.Where are state variables stored?
✗ Incorrect
State variables are stored in the contract's persistent storage on the blockchain.
Explain what state variables are and why they are important in blockchain smart contracts.
Think about how data stays saved between transactions.
You got /3 concepts.
Describe the difference between state variables and local variables in smart contracts.
Consider where each variable lives and how long it lasts.
You got /3 concepts.