Get An Address's Full Transaction History

🐙 Sample code gist

1. First Fetch

Start by fetching transactions from the block 0 up to the latest block.

https://api.etherscan.io/v2/api
   ?chainid=1
   &module=account
   &action=txlist
   &address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
   &startblock=0
   &endblock=latest
   &page=1
   &offset=1000
   &sort=asc
   &apikey=YourApiKeyToken

In most cases, if your address has less than max records ( 1k for free and 5k for paid tiers ), you're good to go

If you receive = max records, its likely that your address has exceeded the query limit.

2. Second Fetch Using Next Block Number

The next block number to start your query from should be the block number of the last record - 1.

https://api.etherscan.io/v2/api
   ?chainid=1
   &module=account
   &action=txlist
   &address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
   &startblock=${lastBlockNumber - 1}
   &endblock=latest
   &page=1
   &offset=1000
   &sort=asc
   &apikey=YourApiKeyToken

This is due to the possibility of transactions from the last block returned being cut off by the limit, particularly if a block contains many transactions to that address.

The transactions from the last block number skipped will subsequently be fully queried in the next request.

3. Rinse And Repeat

Once we receive less than max records limit, we've gotten all 71134 transactions 🎉

This address took approximately 30s to fully pull for free tiers and 10s for paid tiers.

The same pagination applies to ERC20 token transactions, NFT transactions to get an address's full transaction history across 50+ supported chains.

Last updated