Transfers API: Historical Transactions 500x Faster in One Request
From "0x0" to "latest" real quick The fastest, most efficient way to access historical ETH, ERC20, and ERC721 transfers in a single API call.
Imagine if there was a method that could answer: “How much ETH, SUSHI, USDT, … (you get the picture), has Vitalik Buterin sent to Elon Musk?” Well, with Alchemy’s Transfers API, now there is (provided that you know their wallet addresses). With a single API call, you can fetch historical transactions for any address and any tokens, without having to scan the entire chain for each of your users.
Whether you're a developer for the newest DEX or the hottest gaming dApp, you know the struggle is real when it comes to accessing historical transactions.
If you're using the native Ethereum client methods, you're probably querying for each block to get ETH transfers, then filtering for ERC20 and ERC721 transfers by parsing through thousands of logs, and keeping all of this information in some underlying datastore. Aside from being a mouthful, the process of building out this infrastructure in a way that is scalable and consistent takes up a lot of engineering resources and is extremely slow. Don't even get me started on parsing transaction traces to access internal transactions from contract addresses - as Nikola Vuković from DefiSaver puts it, "internal transfers are almost impossible to get".
After learning about this painful process for such a simple and universal use case, we decided to build out our Transfers API that does all of this work behind the scenes. Now, all you have to do is make a call to a single endpoint and watch as the ETH, ERC20 and ERC721 transfers come rolling in. As an added bonus and optimization, this API supports pagination so that you can reduce network latency and fetch results sequentially without hitting timeouts or having to stitch together the results yourself.
Transfers API Infrastructure
Once you've accessed all of the transactions your users have made in the past, you can easily set up Address Activity Notifications to continue to receive ETH, ERC20 and ERC721 in real time. Together, Alchemy's Transfers API and Address Activity Notifications are a powerful tool set for any developer interested in building a backend for user transactions.
Okay, now for the cool stuff - a live demo. To see our Transfers API in action, checkout this example query in our Public Composer to view transfers sent from Uniswap V2: Router 2 to Yearn: Deployer - it's super simple and will help you get started!
Our results show that a call to alchemy_getAssetTransfers is up to 500x faster (and for some use cases literally 1,000,000x faster) than using the geth methods eth_getBlockByNumber and eth_getLogs concurrently to query 10K blocks for all ETH, ERC20 and ERC721 transfers sent to WETH. Don't believe us? A skeptic - I like it. Good thing you can always test the performance yourself with this script. If you want to see the optimization really kick in, try querying for more blocks. If there's a 500x speed up for 10K blocks, imagine the speed up you'll see for 10M blocks 🚀!
If you’re interested in exploring the Transfers API you can get started today by signing up with Alchemy for free and checking out the documentation.
Related articles
Introducing Prices API
Save development time with our new API for real-time and historical token prices.
New Integrations for Rollups partner: Parsec
Say goodbye to confusing block explorers. Parsec brings context and visual transaction flows to your rolllups.
Deeper application insights at lower costs
By re-architecting back end infrastructure, Alchemy has passed up to 3x efficiency savings to you for four key debug_trace methods.