0 votes
1 view
in Blockchain by (12.8k points)

I have a private chain now and I want to query the transaction histories.I know that web3 has provide those methods web3.eth.blockNumber/web3.eth.getBlockTransactionCount/web3.eth.getTransactionFromBlock. So I can get the transaction history by getting latest blocknumber(suppose it's n). Range from n to 0 to call web3.eth.getBlockTransactionCount(i), then get transactions by web3.eth.getTransactionFromBlock. but it's just time-wasting and inefficient. so I'm wondering how can I get transaction histories from blocks efficient via web3 or RPC or any way?

1 Answer

0 votes
by (29.8k points)

HI, i can think of a way to get your job done but this might not be the most efficient way that you are looking for still, what you can do is  For each block you can pass true as the second parameter to getBlock:

web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...