I copied a smart contract and deployed it from my account on Mist on Rinkeby Network.

All functions are working as expected except one. I will post the code here :

event PerformingDrop(uint count);
function drop(address[] addresses, uint256 amount) public onlyOwner {
  uint256 amt = amount * 10**8;
  require(amt > 0);
  require(amt <= SUPPLY_CAP);

  // Maximum drop is 1000 addresses
  assert(addresses.length <= 1000);
  assert(balances[owner] >= amt * addresses.length);
  for (uint i = 0; i < addresses.length; i++) {
    address recipient = addresses[i];
    if(recipient != NULL_ADDRESS) {
      balances[owner] -= amt;
      balances[recipient] += amt;
      Transfer(owner, recipient, amt);

Here is the screenshot of error

I am executing this contract from my main account which has 2.97 ether available.

  • No of Tokens: 10000000.00000000
  • Decimals : 8

I am passing array of addresses as 1st param e.g [‘Address1’, ‘ Address2’] and number of tokens to drop.

Whenever I perform a drop of 10000000 drop works fine but if I increase even 1 more digit let say 100000000 then the error shown in image occurs.

What could be the issue?


I think the issue is this line in the contract,

  uint256 amt = amount * 10**8;

This means that your input number of tokens is being multiplied up to account for the 8 decimal places.

Therefore, your input needs to be in terms of whole tokens. If you have 10000000.00000000 tokens in your account, then your maximum input can be 10000000, divided by the number of addresses. (Incidentally, since you can't input fractions, this means that the 8 decimal places are totally pointless...)

| improve this answer | |
  • Yeah i also believe thats an issue. Let me test and get back to you. – Pankaj Wadhwa Dec 2 '17 at 17:35
  • After i removed "* 10**8" from that statement i didn't get that error and transaction runs successfully but tokens dropped are not showing up in the receivers account. – Pankaj Wadhwa Dec 3 '17 at 9:43
  • I wasn't really suggesting removing that line, just being aware of it so that your input amount, transaction amount and decimals parameter are all consistent. If you do remove it, then you can set decimals to zero and everything will be much clearer (you'll always be dealing in whole tokens throughout, so no confusion). – benjaminion Dec 3 '17 at 9:55
  • what are the drawbacks of not having decimals? – Pankaj Wadhwa Dec 3 '17 at 14:18
  • None at all, in my view: they seem to be an endless source of confusion. In ERC20, the decimals parameter is just for the UI - it has no internal meaning in the contract. Some UIs handle it and some don't, just adding to the confusion. Better off without, I say. But decimals might make sense in some use cases, so the facility is there if you want it. – benjaminion Dec 3 '17 at 15:59

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.