Reputation: 87
If I use w3.eth.getBlock('latest').number
to get the latest block_number, will 0 ... block_number include the entire universe of Ethereum blocks? This answer seems to suggest this is the way to get a wallet's transaction history.
results = {}
block_latest = w3.eth.getBlock('latest').number
for block_item in range(0,int(block_latest)):
# check each block for matching transactions
# and return them in result
results[block] = result
Upvotes: 0
Views: 563
Reputation: 87
Yes, block numbers are consecutive on the Ethereum blockchain. To get a wallets history without libraries or APIs you would have to loop through every block but a better alternative (as Frank said in comments) is to use the Etherscan API. The API call will probably look like:
https://api.etherscan.io/api
?module=account
&action=txlist
&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a
&startblock=0
&endblock=99999999
&page=1
&offset=10
&sort=asc
&apikey=YourApiKeyToken
Upvotes: 1