Recall & Review
beginner
What is a constant in blockchain programming?
A constant is a value that is set once and cannot be changed during the execution of a smart contract. It helps keep data safe and predictable.
Click to reveal answer
beginner
What does 'immutable' mean in the context of blockchain variables?
Immutable means the variable can be assigned only once during contract creation and cannot be changed afterward, ensuring fixed data after deployment.
Click to reveal answer
intermediate
Why use constants and immutables in smart contracts?
They save gas (transaction cost) and increase security by preventing accidental or malicious changes to important values.
Click to reveal answer
intermediate
How do constants differ from immutables in blockchain code?
Constants are fixed at compile time and cannot be changed ever. Immutables are set once during contract deployment and then stay fixed.
Click to reveal answer
beginner
Example: What happens if you try to change a constant value in a smart contract?
The code will not compile or will throw an error because constants cannot be modified after they are set.
Click to reveal answer
Which of the following is true about constants in blockchain smart contracts?
✗ Incorrect
Constants are fixed values set at compile time and cannot be changed.
What is the main difference between constants and immutables?
✗ Incorrect
Constants are fixed at compile time, while immutables are assigned once during contract deployment.
Why do constants and immutables save gas in smart contracts?
✗ Incorrect
Fixed values reduce storage and computation costs, saving gas.
When can an immutable variable be assigned a value?
✗ Incorrect
Immutables are assigned once during deployment and then cannot be changed.
What happens if you try to modify a constant after deployment?
✗ Incorrect
Constants cannot be modified; attempting to do so causes compile errors.
Explain the difference between constants and immutables in blockchain smart contracts.
Think about when each value is assigned and if it can change later.
You got /4 concepts.
Why is it important to use constants and immutables in smart contract development?
Consider how fixed values help protect your contract and save costs.
You got /4 concepts.