If I have a Contract A receiving 50000 'XXX' tokens from a contract B, those tokens are supposed to be distributed across 5 whitelisted users who has pooled 'xx' Ether into contract A, how can I make sure they get the correct amount of tokens? not sure how to calculate this, cheers.


something like

for (uint i = 0; i < whitelistedOwners.length; i++) {
    ethBalance[whitelistedOwners[i]] * 10000 / totalEthInvested

which will give you a percent (because solidity only handle integer, I multiplied by 10000 to have 4 decimal numbers available) and then multiply this result by the total tokens available

  • "because solidity only handle integer", I don't believe this is necessary, solidity handles integers in same way, either way, however it does allow us to work with less zeroes
    – NowsyMe
    May 21 '18 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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