Reputation: 71
I am new to block chain. Suddenly I got a question did we can able to access the previous block data from the Ethereum block chain by block number.
For example I have created a block1, block2.
block1 has data 'apple' after that I have changed the data to 'banana' so new block is created block 2. I know if we call the get data function then it going to give output banana but in case I want to access the data from the block1 through the block number as 1 how to access it?
There is any way to access the data from previous block it there please help my question to solve.
Thanks.
Upvotes: 3
Views: 1837
Reputation: 13
The Graph Protocol can help index historical information if you need to access to it laster.
Upvotes: 1
Reputation: 43521
You can access previous state at a specific block using offchain tools. For example the web3js method call()
(docs) allows you to specify a block number that you want to query.
However, onchain contracts do not have access to previous blocks.
Upvotes: 5