r/EthereumProgramming • u/chelo_c • Feb 21 '18
Question about iterate through mapping
Hello, I am looking for a way to iterate through a mapping. For example I have this mapping: mapping (address => uint) private shares;
And I want to iterate in a function through all addresses and send them ether according to their shares.
How can I achieve this?
Thanks
1
Upvotes
View all comments
Show parent comment
2
u/drlecks Feb 21 '18
It all depends on your needs/design. Iterating the "_totalHolders" will consume gas, of course, more if you plan to send ETH, and more as the counter increases.
So you should consider if you want to pay a relatively high amount of gas yourself and serve the ETH automatically to the users. Or if you want to save transference cost on your side and authorise holders to withdraw ETH paying themselves the transaction fee.
As I said, it all depends on your needs/design.