1

I am wondering about Smart Contracts: as such, they reside inside the Blockchain, this means they have to be stateless. If the state of a SC changes (i.e. changing the value of a variable), the hash value of the overall SC changes and as a consequence the Blockchain is broken.

So, where is the stateful data stored? Or does it mean that each time stateful data (i.e. value of variables) change, the same SC will be stored again and again on the Blockchain, meaning a multitude of instances of the same SC?

1
  • I'm pretty sure this is the same as the above question. If that question doesn't cover what you're asking, then let us know the specifics of what you'd like to know :-) May 1 '17 at 17:17
0

I think you should read the official doc. each account (including contract account) has a separated storage which change of state. A smart contract acte like a script running in a webserver wich receives transactions and communicate with a separated DB to change the variable's states.

in the doc you'll find

Every account has a persistent key-value store mapping 256-bit words to 256-bit words called storage.

so the contract itself don't change we have only one instance but the related storage does.

i think this illustration may help you to visualise the separation between the code and the storage. enter image description here

2
  • in the illustration, why is "Account B" stored in each Block, even is there is no activity whatsover concerning this account (although suddently in block 3 it has less ether...)?
    – solider
    May 15 '17 at 12:48
  • the Tx2 is From B to account C there is an error in the graphe
    – Badr Bellaj
    May 15 '17 at 13:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.