- I want to create a token that will allow an effective way to iterate through and update dividend values per token holder address. With my current idea, I'd have to manage 2 structures to keep ERC20 standard and be able to iterate through and calculate/store dividends (calculation will be divided into n steps due to gas limits). Is there any better way to implement dividends in current ERC20 standard?
ERC20 Token balances
mapping (address => uint256) public balances;
Array to store tokens and dividends
struct TokenDividend
{
address addr;
uint divident;
}
Token[] public tokenDividends;
Users will be able to withdraw their rewards with withdraw() function, the problem here is that each user would have to iterate over tokenDividends array, this would cause out of gas errors at some point:
function withdraw() returns (bool) {}
What are current plans about token standard?
Is it possible to use iterable mapping as a token standard structure? https://github.com/chriseth/solidity-examples/blob/master/iterable_mapping.sol
Are there any new structures planned to be added to Solidity?
Should I combine standard mapping and iterable mapping to manage dividends and keep ERC20 token standard?
Update: I have a requirement to add dividends weekly, all of the token holders have to be treated equally, users with small amounts of tokens will earn small dividends, those dividends will need to be accumulated over time so users won't spend more than they earn when withdrawing their rewards. Token will be tradable.
Similar question: ERC20 Tokens with Rewards?