-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Listing all transactions of a wallet #326
Comments
The Fortunately, Etherscan supports what you are trying to accomplish. :) let provider = new ethers.providers.EtherscanProvider();
let history = await provider.getHistory(address); This is possible because Etherscan has independently indexed all this data in their own, much more complex DB. Let me know if you have any issues with this method. :) |
@ricmoo thanks for reply, however this kinda feels sub-optimal (it does work what I want)
reading the docs helped, forget my ignorance... Cheers |
Oh, the I agree it isn’t ideal, but the data isn’t actually indexed in the node, so access to it isn’t really available, even passing a block height into the |
Oh! Haha. Good timing. :) |
Im going to close this now, but if you have any more issues, please feel free to re-open. Thanks! :) |
too bad that it doesn't support ropsten! |
@Amirhb It should support Ropsten. What address are you using? I’ve used it on Ropsten. |
@ricmoo I just instantiated ethers and used the code snippet you mentioned above. The history fetched out from the mainnet. Am I missing something? |
@Amirhb Oh, well yes; the above sample connects to mainnet. :) To connect to Ropsten, use:
For more info, check out the documentation for the Providers. And let me know if you have any other issues. |
@ricmoo Thank you so much |
@ricmoo Has anyone had any issues with Looking to use the default EtherscanProvider() to retrieve wallet transactions but concerned etherscan will hit rate limit. |
Is there an alternative to etherscan for transaction history? |
I’ve used I’ve been building out some libraries to help mitigate this and will be sharing them, but it is certainly non-trivial... |
In 5.4, where to find the doc for |
For anyone that stumbles onto this from Google, v5 docs haven't been updated. Here is the function itself -
Example - const currentBlock= await provider.getBlockNumber()
const blockTime = 15; // ETH block time is 15 seconds
//Block number 2 hours, 24 hours and 48 hours ago
const block2 = currentBlock - (2 * 60 * 60 / blockTime);
const block24 = currentBlock - (24 * 60 * 60 / blockTime);
const block48 = currentBlock - (48 * 60 * 60 / blockTime);
// Get all txs for address since 2 hours ago
let history = await provider.getHistory(address, block2, currentBlock);
// If you got nothing back (i.e no txns), try 24 hours and then 48 hours
(history.length === 0 ? history = await provider.getHistory(address, block24, currentBlock) : null);
(history.length === 0 ? history = await provider.getHistory(address, block48, currentBlock) : null); |
The Ethers.js documentation now has an entry for the Etherscan provider (https://docs.ethers.io/v5/api/providers/api-providers/#EtherscanProvider), but the documentation for the |
Thank you. |
Does the EtherscanProvider work also with Etherscan-compatible stuff, like Polygon Scan or BNB Scan? |
Any updates on how to do this on other chains? Seems to only be compatible with etherscan based chains, and have not found an equivalent for chains like Polygon, Optimism, Avalanche, etc... |
It seems like this doesn't provide the full history, bc incoming transactions from ERC 20 contracts are missing. If you look for instance at hayden.eth, This one for instance is missing, even though it deposits tokens into the contract: https://etherscan.io/tx/0xe632460600b0b967c95f0d39caedd17dee495ae7b8d6004c00442d65dc4c5c28 I'm trying to plot the balance over time in my app (merklin.xyz), which doesn't work with this method. Is there any solution to get all incoming and outgoing transactions? |
@toniengelhardt the Etherscan API does separate out "transactions" (non-token transactions initiated by the requested address) from "ERC20 token transfers", as well as "ERC721 token transfers" and other "internal transactions". Their API does have a way to query the ERC20 token transfers (https://docs.etherscan.io/api-endpoints/accounts#get-a-list-of-erc20-token-transfer-events-by-address), which you could query that way, though that's not as convenient as using a "provider" |
Thanks so much @MidnightLightning, this looks very promising! I'll give it a shot. |
Is it possible to achieve this with v6? |
Hello. My intentions are to list all balance changes of a particular wallet (address provided).
However this callback is never called. Is there a reason why?
The text was updated successfully, but these errors were encountered: