Is there any way to retrieve all holders account of a particular token in solidity?
Oct 2, 2020, 3:02 PM
Or should I add additional function in erc20 for tracking each transfer call...
Oct 2, 2020, 3:04 PM
I've seen some tools online that allow this.
https://etherscan.io/token/0xa74476443119A942dE498590Fe1f2454d7D4aC0d#balances
It's right on etherscan
That one only shows the top 1,000 holders. But I'm 100% sure you can get a complete list somewhere.
Oct 2, 2020, 3:12 PM
Yeah I know etherscan does it. But was actually looking for a way with solidity itself
Oct 2, 2020, 4:42 PM
I'm not sure about that... I guess I can look at the ERC20 spec for a second and tell you
Okay, so you need to store that information in your contract, and then you can query it. If you're talking about querying an existing contract, then probably not, unless the contract owner has created a holders array
Oct 2, 2020, 4:50 PM
That array might become huge. Anyway, its not gonna cost additional gas, so why not :)
Thanks
Oct 2, 2020, 6:11 PM
Well, the array exists already (_accounts) what you are doing is exposing it.
Don't take what I am saying as gospel, though. DYOR
Oct 2, 2020, 6:12 PM
Umm on which version is the _accounts present?
I am using openzepplin 0.5.0 one
it doesn't have that
Oct 2, 2020, 6:13 PM
_balances, I'm sorry
Oct 2, 2020, 6:17 PM
Version 0.7.2 still utilizes that syntax: balances[_account]; or return _other.balance. I’m not sure what your question is specifically? Also common practice in earlier versions like v4.2
Oct 2, 2020, 8:51 PM
Nvm it was regarding an array name
Oct 2, 2020, 9:27 PM