I have an airdrop function that allow the owner input array of addresses and an amount to give. It work well with small number of addresses about (100) but bigger than that, gaz limit is reached.

I wonder, is it my code that block that or just the fact that it cost X amount to airdrop X token multiply by the array length so it's just costing a lot to send and the gaz limit really reached?

I tried to find answer here and over the web but I'm not sure how to format my question. Like, is there any limit of an address array as argument?

Here is my code :

function airDrop(address[] recipients,uint amount ) public {

      require(msg.sender == owner);
          require(amount > 0);

         uint256 supposedDropAmount = (recipients.length).mul(amount);
      //be sure it's not over the limit

      uint256 checkedSupply = dropAmount.add(supposedDropAmount);

      // return money if something goes wrong

     require(checkedSupply <= AirdropCap); // block airdrop 

      //require date time
       require(now > airdropTime);

      for( uint256 i = 0 ; i < recipients.length ; i++ ) {

           assert(token.mint(recipients[i], amount));
          emit  TokenDrop( recipients[i], amount );
    numDrops = numDrops.add(recipients.length);
    dropAmount = dropAmount.add(recipients.length.mul(amount));

Notice the token.mint is external in another contract, and that airdropTime is much in the past than now. As I said, it work with small array of address.


2 Answers 2


Not only are you connecting to an external contract, but that you are also responsible for the storage costs to said contract as well as your contract...

It's definitely the gas limit...and unfortunately, using a smaller array of addresses is the only option.

  • what do you mean by "but that you are also responsible for the storage costs to said contract as well as your contract"? I didn't understand sorry. Also, would making the external part in the same contract would help?
    – btc4cash
    Commented Mar 19, 2018 at 22:02
  • @btc4cash Well, you are minting tokens to an external token contract. That contract has to also store that data within itself. The gas cost of storing token data on that contract is passed to the user of the airDrop function. You also seem to store data in this contract...which also adds to your gas cost.
    – ReyHaynes
    Commented Mar 19, 2018 at 22:09
  • so way to allow this function to accept more addresses as arguments would be putting the function in the external contract itself, so it would cost less gaz calling it since less data stored and no external call?
    – btc4cash
    Commented Mar 19, 2018 at 22:10
  • @btc4cash That'll squeeze you a few more addresses...but the most expensive performance on EVM is storage cost. A direct storage costs about 20,000 gas if saving from a zero value. Adding 500 new addresses would essentially cost 10 million gas, but the limit on the mainnet is 3 million.
    – ReyHaynes
    Commented Mar 19, 2018 at 22:15
  • But mate, I have no plan storing theses address! I just want to use them as destination, give them token, that's it! Do you mean I just can't use that much of array data for anything in the EVM?
    – btc4cash
    Commented Mar 19, 2018 at 22:16

Use IPFS to store that data and then call your array from IPFS

  • According to what I know and ethereum.stackexchange.com/q/7664/19037 IPSF not fetchable from the solidity contract, I would need to use oracle which is costly in gaz. This is much more complicate solution for the probleme I have
    – btc4cash
    Commented Mar 22, 2018 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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