vishwa_001
vishwa_001

Reputation: 71

How to access the data from the previous block of Ethereum block chain through the block number?

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

Answers (2)

kraphty23
kraphty23

Reputation: 13

The Graph Protocol can help index historical information if you need to access to it laster.

Upvotes: 1

Petr Hejda
Petr Hejda

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

Related Questions