I want to provide a feature to download balances in open zeppelins StandardToken

    mapping(address => uint256) balances;

Probem is I get this error :

    Internal type is not allowed for public or external functions.

How can I do it ? I imagine it has to be done in phases, like one method for downloading all the addresses, and second method to retrieve the balance for one particular user. Which leads to another question - how to iterate through the mapping and just return array of address.


In my usecase, I have an ESO type option where the startup's employees are given away certain number of tokens for free. This happens by invoking some function marked as "onlyOwner", by the owner. This would not be reflected in the block logs, because there is no ether being transferred to the contract. In the other answer linked, it only deals with the case where the user sent ETH to a particular address.


Its generally a bad idea to iterate through arrays to which the size we don't know. When working with small fixed size arrays, its not really much of a problem. However, iterating through an array of balances could be extremely computationally expensive for the Ethereum Virtual Machine. Each iteration would increase the gas cost. Imagine there are 100,000 addresses stored in the array of balances, this would most certainly exceed the gas limit which is approximately 4,700,000 gas.

  • is there gas involved even in a read only operation ?
    – MD Luffy
    Oct 23 '17 at 18:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.