0

Let's say I want to airdrop various amounts of an ERC20 token to 10,000 different wallets.

How/Why is a smart contract that handles the airdrop in batches (as described here) is cheaper in gas than 10K singular transactions, each for every recipient?

I mean, the EVM bytecode to run both methods should end up quite the same, doesn't it?

1 Answer 1

1

It depends on implementation, ERC20 token used, how batch transfer was programmed, etc. I'd not say it will always be cheaper.

For any transaction you have to pay minimum 21k, plus the cost of a transfer. If you have 10 transfers in a batch you still have to pay the minimum 21k, but it will be paying only an extra 2.1k gas per tranfer.

You will be doing some extra work like updating the loop index, checking the array bounds, etc. but if that extra cost is less than 21k gas you will save some gas.

2
  • I started running the airdrop in batches on rinkeby and noticed something buffling: same transaction always consumes different amount of gas. How come? shouldn't each identical transactions consume the exact same amount of gas?
    – shaharsol
    Commented Jul 2, 2018 at 9:35
  • 1
    It is better if you ask a new question about that. Opcode costs depends on the context, modifying the balance of an existing user is cheaper than creating a new user balance. Input data have different costs for zero bytes than for non-zero bytes, etc.
    – Ismael
    Commented Jul 2, 2018 at 14:36

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.