I'm new to block chain technology. I'm trying to store and read blocks using testRPC along web3.js. I'm able to get the latest block data but not able to fetch previous blocks data. Please some one tell me how can I get it.
1 Answer
You can use:
web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])
checkout web3 documentation: https://web3js.readthedocs.io/en/1.0/web3-eth.html#getblock
-
I've already tried this. This gives the details of the block with hashes but not the actual data. Commented Sep 26, 2018 at 12:23
-
What specifically do you need from the block? The returned info will tell you the transactions included in the block, e.g.:
"transactions": [ "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b" ],
And with that, you can call (on each of those):web3.eth.getTransaction(transactionHash [, callback])
Commented Jul 22, 2022 at 20:36