3

I am trying to understand where are the smart contracts actually stored. On most of the websites where I managed to get some info, it says that smart contracts are stored on the blockchain, but they also do not go in depth on how it is actually stored. On the other side, all the technical information I found with diagrams shows complete opposite - it usually shows that only the root of the Account Trie is stored in the World State Trie and then its root is stored on the blockchain. That means that only (so to say) the pointer to the smart contract is stored on the blockchain, not the actual contract itself. Is that correct?

That also leads me to question, how are the tries actually stored? Just independently as some files on every node?

1 Answer 1

4

from the ethereum yellow paper

The world state, is a mapping between addresses and account states (a data structure serialised as RLP). Though not stored on the blockchain, it is assumed that the implementation will maintain this mapping in a modified Merkle Patricia tree. The trie requires a simple database backend that maintains a mapping of byte arrays to byte arrays; we name this underlying database the state database

take a look at the following diagram from here

enter image description here

again from the ethereum yellow paper:

codeHash: The hash of the EVM code of this account— this is the code that gets executed should this address receive a message call; it is immutable and thus, unlike all other fields, cannot be changed after construction. All such code fragments are contained in the state database under their corresponding hashes for later retrieval.

you can read more about the ethereum data structures here and here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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