I am new to blockchain. I have some idea about blockchain and solidity. Smart contract get stored on blockchain as byte code. And the state variables we create also stored in blockchain. How is it possible to change the state variable once we have deployed the contract ?
1 Answer
The state variables can be changed. What is immutable in itself is the contract, or its bytecode.
You cannot add, remove, modify functions or content (events,modifier, ...). Since that would modify the bytecode. State variables' state are stored in storage. That's what is modified, the storage not the actual bytecode.
You cannot add sate variables once deployed, only modify the stored value of existing ones or delete them (resetting their value to the default zero value actually) if you have created the necessary functionalities.
Here are good explanations of how it all works, EVM, memory , storage, stack ...
https://github.com/ethereumbook/ethereumbook/blob/develop/07smart-contracts-solidity.asciidoc
https://github.com/ethereumbook/ethereumbook/blob/develop/13evm.asciidoc#what-is-the-evm