An idea of BulkAirdrop gas saving
Assume 2^24 amount of users are being stored to "address[] users_section1", assume balances are being stored to "bytes balances_section1" with filling them by 3 bytes (uint24) hexadecimal string with decimal=0 which is being carefully corresponded with users index (3 bytes data x 2^24 is the length of the balances_section1), and assume the same data structure with balances_section1 variable is being stored to the "bytes allowance_section1".

  • In this way, 50,331,648 bytes (50.3MB) is the required storage size for storing entire balances of users_section1 of this protocol. Every time you have get 16,777,216 users, the next user will be in the fresh "address[] users_section2", "bytes balances_section2", and "bytes allowance_section2" data structures.

  • This structure can only be extended until "address[] users_section256", "bytes balances_section256", and "bytes allowance_section256" because this protocol intends to accommodate only 2^32 users (4.2 billion).


The airdrop function is like "function bulkTransfer(uint8 sectionIndex, uint24[] amount) public onlyOwner (returns bool)" and this function maximally should be run 256 times to finish airdrop, but when users are relatively a few (2^24=16,777,216 ppl), 1 time is enough.


So, modifying 16,777,216 ppl's 3 bytes balance data implies that 50.3MB data modification is happening for this airdrop.

  • Precisely, for this protocol's airdropping procedure, only the owner is the source of being-airdropped token and so "transfer" function is an enough behavior for this airdrop rather than allowance-modifying "transferFrom()".

  • So I suggest "function bulkTransfer(uint8 sectionIndex, uint24[] amount) public onlyOwner (returns bool)" is a modification to 150.9MB bytes. It might be so much cheaper than 2^24 "for looping" of normal ERC-20 transfer.


Given the gas cost for each byte to be around 68.5 gas per byte. This is based on the current gas cost of a simple SSTORE operation in the Ethereum Virtual Machine (EVM). The gas needed to update 50.3 bytes in EVM is 3,447,717,888 gas.


If this protocol runs on the L2 rollup, gas cost would be 0.1 gwei per gas (assume there will be proto-danksharding is the Cancun-Deneb upgrade, it will be x100 cheaper. And notablly, Arbitrum doesn't have block gas limit (which is 30,000,000 in the mainnet) and so this large function won't be stopped.)

  • So, assume we got 0.001 gwei environment, an airdrop is 0.00344771788 ETH.