- Toshendra Kumar Sharma
- March 12, 2019
Since 2009, we have heard a lot about Blockchain, its application, and growth. There are some positives and negatives to this technology. But, one common thing is that this technology is growing at a faster pace. When we talk about Blockchain, then there is another parameter that we should not, and that’s data storage. We all know that Blockchain is a ledger which allows the exchange of information and this information is stored in the ledger. Well, our focus in this blog would be on Ethereum. It is not just a cryptocurrency, and there is much more to it. Till now we had discussed use cases of Blockchain, but here we will talk about data storage on Ethereum Blockchain.
Ethereum Blockchain
Ethereum is an open source Blockchain platform that allows the creation of decentralized applications, and It is a distributed public blockchain network. Ethereum Blokchian focusses on providing a platform for seamless running of codes for any decentralized application.
Unlike Bitcoin, Ethereum Blockhian allows the miners to work to earn Ether. Ether is a token that will enable the entire system function. In the Ethereum blockchain, there is another type of token which is used to pay the miners; it is known as gas. Every smart contact for its execution requires a certain amount of gas to be sent to the miners to put it in the Blockchain.
We all know a lot about the smart contract and how do they function. These pre-programmed contracts have a certain set of conditions agreed between two parties, once the conditions are met, the contract executes, and the processing of payment takes place. Now the question that arises here is how does the backend operation perform here. How is the data stored on Ethereum blockchain? Well, let us try exploring the answer ahead.
How is data stored in Ethereum?
The data on Ethereum Blockchain is stored using tire data structures. Before going ahead, we would like you to know that it is completely sensible that permanent data like mined transaction and temporary data like account balance should be stored separately. Ethereum makes use of this trie data structure to manage temporary and permanent data. We can say that Etherum is like a bank.
Only after a transaction is confirmed, then it is recorded in the transaction trie. Ephemeral or temporary data like account address is stored in the state trie, and it changes and gets updated. Thus it makes complete sense to keep both temporary and permanent should be stored separately and hence we have three tries for managing and storing data.
Detailed description
As mentioned above, Ethereum stores and manages data using a trie. There three types of the trie in the Ethereum Blockchain:
- State Trie
- Storage Trie
- And Transaction Trie
State trie
You must know that there is only one State Trie, Global State Trie in Ethereum. It gets constantly updated. The state trie consists of a key and value for every account which is present on the Ethereum account. This key is a 160-bit identifier.
Storage trie
As the name itself indicates, storage trie is where the contract data is present. Every ethereum account has its storage trie. 256-bit hash of the storage trie’s root node is stored in the global state trie as storageRoot.
Transaction trie
Every Ethereum block has its transaction trie. Every block contains transactions. The order of the transaction present in every block is based on the course of addition of transaction to the block. The position of the block never changes, the path of a particular transaction is via the index of where the transaction sits in the block. In simple words, it means, that you can locate transaction you can go back on the same path again and again and get the same result.
An important point to note here is that data like account balance are not stores directly in the blocks. Only the root node hashes of the transaction trie, recept trie and state tries are stored in the Blockchain.
Conclusion
Ethereum Blockchain functioning is fairly simple, the division of permanent and temporary data in different tries ensures that data is safe and the data is easily manageable. The data stored on blockchain as smart contracts are safe and easy to access.