6

how could I go about sending tokens to a couple of thousands of addresses without havinging to do it manually? It's an airdrop.

5
  • A contract might be able to take care of but in a way that might surprise. Can you be more specific? Are there particular accounts, specific amounts, or just a pile for the asking in even amounts for anyone with an ethereum address? Commented Oct 23, 2017 at 22:05
  • it will cost you some money, why not to make an ICO-like contract. people gets directly the tokens instead droping tks to a bunch of addresses.
    – Badr Bellaj
    Commented Oct 23, 2017 at 22:58
  • It's a specific amount to be sent to many addresses. I can't do it manually because that would take a couple of days
    – Vini
    Commented Oct 24, 2017 at 6:18
  • 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
    Commented Nov 22, 2017 at 7:49
  • where to include the list of address in the code? how does the code read the list of address to which the tokens should be sent?
    – IGCGamers
    Commented Feb 9, 2018 at 13:52

3 Answers 3

6

OmiseGo just released their Airdropper contract that Vitalik purportedly wrote the original version of. It sends many values to many addresses.

It's fairly straightforward: you pass an array of addresses and an array of values and iterate through them sending the funds to each address.

contract Airdropper is Ownable {

    function multisend(address _tokenAddr, address[] dests, uint256[] values)
    onlyOwner
    returns (uint256) {
        uint256 i = 0;
        while (i < dests.length) {
            ERC20(_tokenAddr).transfer(dests[i], values[i]);
            i += 1;
        }
        return(i);
    }
}
3
  • How many addresses in maximum can I send? Commented Jan 29, 2018 at 9:50
  • you're constrained by gas costs
    – JohnAllen
    Commented Jan 29, 2018 at 20:30
  • Is this contract already deployed on livenet? Commented Feb 9, 2018 at 13:55
1

You can do it with a contract in a few ways.

You could use a "pull/withdraw" pattern. Create a contract where users request to withdraw the airdropped tokens and you keep a balance of how many tokens a given address has withdrawn. You could also create a whitelist/blacklist of addresses to allow/disallow certain addresses to receive the tokens.

You can also do it the other way around. Create a contract where people signup by entering their address, and then when you decide so, you can call a function that iterates over the array of addresses and sends them the tokens. The problem with this approach is that is more prone to problems if the list is big enough that there's not enough gas to perform this transaction. You could code it to perform the airdrop in batches to prevent this problem. If it's just a few thousand addresses you should be fine, though.

2
  • How would one go by doing this
    – Vini
    Commented Oct 24, 2017 at 6:20
  • How can I do pull/withdraw pattern for 7500 addresses? Commented Dec 17, 2021 at 7:16
1

You can automate sending tokens to multiple addresses using a script or a smart contract function. Here’s a basic approach using a smart contract in Solidity:

pragma solidity ^0.8.0;

import "IERC20.sol";

contract Airdrop {
    function distributeTokens(address tokenAddress, address[] memory recipients, uint[] memory amounts) external {
        require(recipients.length == amounts.length, "Arrays length mismatch");

        IERC20 token = IERC20(tokenAddress);
        
        for (uint i = 0; i < recipients.length; i++) {
            token.transferFrom(msg.sender, recipients[i], amounts[i]);
        }
    }
}

This distributeTokens function takes an ERC-20 token address (tokenAddress), an array of recipient addresses (recipients), and an array of corresponding token amounts (amounts). It transfers tokens to each recipient in a single transaction.

Alternatively, consider using Off Grid Platform's Bulk Sender for a more streamlined approach to managing large-scale token distributions. You can explore more about it here: OGP Bulk Sender.

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.