Overview - Constants and immutables
What is it?
Constants and immutables are special types of variables in blockchain programming that cannot be changed after they are set. Constants are fixed values known at compile time, while immutables are set once during contract creation and then stay the same. They help keep important data safe and predictable throughout the life of a smart contract.
Why it matters
Without constants and immutables, smart contracts could accidentally or maliciously change critical values, causing bugs or security risks. They make contracts more reliable and cheaper to run by saving storage and gas costs. Imagine a contract where the owner address or token supply could change unexpectedly — that would break trust and functionality.
Where it fits
Before learning constants and immutables, you should understand basic variables and how smart contracts store data. After this, you can learn about gas optimization, security best practices, and advanced contract design patterns that rely on fixed data.