Nflv22
Nflv22

Reputation: 29

Smart Contract's state variables on the blockchain

I am new to blockchain, please help me understand.

How the smart contract's state variables are stored on the blockchain if a smart contract is immutable (because it was deployed as a transaction = byte-code is stored in a transaction)?

Ok, maybe every new state of a state variable is stored with a new method-update call (set) in the transaction, but how then does the smart contract know how to address them if it was created earlier?

And here I found a mention of a state storage on every EVM. "Technically you don’t need to store this on disk, you could just play back all transactions when you boot up the node" - again, how it is possible to play back all transactions related to a contract, how are they connected to a contract?

Upvotes: 1

Views: 571

Answers (1)

Mad Jackal
Mad Jackal

Reputation: 1249

Immutability applies only to data placed directly in the blockchain, that is, to transaction data. In Ethereum, the values of smart contract variables are determined specifically by each node when processing a transaction on its EVM instance. As for, for example, Hyperledger Fabric, the final results of calculations are also transmitted along with the transaction, and the node simply records them in its state database. But at the same time, he himself determines whether to accept or not to accept this transaction.

Upvotes: 1

Related Questions