6

I am trying to host an airdrop but sending the tokens individually to thousands of people would take forever. Is there a way to do it in one transaction with multiple recipients.

If so, could you please provide me with some code.

Thanks

  • Am adding comment here to help people trying to do via mist after created their token to refer here ethereum.stackexchange.com/a/31332/20357 – Rajesh Nov 22 '17 at 7:49
  • This changes a lot if you mean sending ether or sending ERC20 tokens. – Davide C Jan 27 '18 at 10:58
5

You are quite discouraged to use the sending pattern, especially if you want to send/transfer funds (ether/tokens etc.) to thousands of people as you mentioned. This way you can easily get self-pwned by running out of gas, for instance. Have a look at this (and the next slide). Another problem with the sending pattern is that you should have in mind that there is no guarantee that the .send() (or .transfer()) function will succeed. You should be always prepared for such edge cases in your smart contract code, i.e. bail out, work arounds etc. Perfect example for this is the KingOfTheEtherThrone 'hack'.

Therefore you should use the withdrawal pattern, where your users/partners will withdraw their funds, you should not get involved sending funds around. The withdrawal pattern is greatly explained here.

|improve this answer|||||
  • 2
    This answer applies to send( ) of ether, the question was about sending tokens, which is not about sending anything actually but invoking transfer() in a ERC20 contract – Davide C Jan 27 '18 at 10:56
  • Made some edit to reflect your just comment! Thanks! – István András Seres Sep 7 '18 at 21:58
1

On chain you would have to use a contract with something like a sendToMany function:

function sendToMany(address[] recipients) {
for(uint i = 0; i< recipients.length; i++){
     i.send(msg.value/recipients.length);
     }
}
|improve this answer|||||
1

This article gives a good solution.

  • Have all your addesses in a CSV file (remove blanks or erroneous addresses first)
  • Make an airdropTokens(address[] addresses, value) function in your token contract that transfers value tokens to each address with a for loop.
  • Write a scipt to call the function the entries of your CSV file. The article recommends to slice your data, calling the function by batches of 80 (in his example). Calling a function with a very large array might be inefficient.

The article gives more detail but basically that's all you need.

|improve this answer|||||
1

You can use this open-source tool - http://bulktokensending.online It allows generating ETH addresses also. The source is here https://github.com/bulktokensending/bulktokensending

|improve this answer|||||

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