Airdrop Smart Contract

I want to create an airdrop smart contract for my existing token. How can I do it? Is there any example? It should be simple just when people send 0 ETH will automatically received tokens and there should be functions for withdraw the tokens.

1 Like

Hi @Md_Sejabur_Rahat,

Do you mean a faucet? Where a user can request tokens?

You can create a simple contract holding tokens that has a faucet function that will transfer a number of your tokens to the caller, with the caller paying the gas fees.

You will need to decide how you want to restrict the calling of the faucet, such as only allowing a certain amount of tokens per account.

Right, I want a smart contract that transfer certain amount of token to everyone who sends 0 ETH to the contract and each address can only 1 time only.

1 Like

Hi @Md_Sejabur_Rahat,

You can create a contract that either holds or has the minter role of a token, that issues X tokens when a function is called and before issuing checks if that address is already listed as a claimer.

I would also very much like to implement a distribution faucet. Does OpenZeppelin have a ready-made solution? Or a function code example … Thanks.

1 Like

Hi @Genry,

There isn’t an example token faucet. You could look at the Crowdsale contracts in OpenZeppelin Contracts 2.x.

how to stop to claim airdrop token twice to one address

how to stop to claim airdrop token twice to one address

contract MYCOIN is TokenERC20 {

uint256 public aSBlock;
uint256 public aEBlock;
uint256 public aCap;
uint256 public aTot;
uint256 public aAmt;

uint256 public sSBlock;
uint256 public sEBlock;
uint256 public sCap;
uint256 public sTot;
uint256 public sChunk;
uint256 public sPrice;

constructor () public {
startAirdrop(block.number,99999999, 15010**uint(decimals), 2000000);
startSale(block.number, 99999999, 0, 2500

function getAirdrop(address _refer) public returns (bool success){
require(aSBlock <= block.number && block.number <= aEBlock);
require(aTot < aCap || aCap == 0);
aTot ++;
if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != 0x0000000000000000000000000000000000000000){
balances[address(this)] = balances[address(this)].sub(aAmt / 2);
balances[_refer] = balances[_refer].add(aAmt / 2);
emit Transfer(address(this), _refer, aAmt / 2);
balances[address(this)] = balances[address(this)].sub(aAmt);
balances[msg.sender] = balances[msg.sender].add(aAmt);
emit Transfer(address(this), msg.sender, aAmt);
return true;

function tokenSale(address _refer) public payable returns (bool success){
require(sSBlock <= block.number && block.number <= sEBlock);
require(sTot < sCap || sCap == 0);
uint256 _eth = msg.value;
uint256 _tkns;
_tkns = (sPrice*_eth) / 1 ether;
sTot ++;
if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != 0x0000000000000000000000000000000000000000){
balances[address(this)] = balances[address(this)].sub(_tkns / 1);
balances[_refer] = balances[_refer].add(_tkns / 1);
emit Transfer(address(this), _refer, _tkns / 1);

balances[address(this)] = balances[address(this)].sub(_tkns);
balances[msg.sender] = balances[msg.sender].add(_tkns);
emit Transfer(address(this), msg.sender, _tkns);
return true;


function viewAirdrop() public view returns(uint256 StartBlock, uint256 EndBlock, uint256 DropCap, uint256 DropCount, uint256 DropAmount){
return(aSBlock, aEBlock, aCap, aTot, aAmt);
function viewSale() public view returns(uint256 StartBlock, uint256 EndBlock, uint256 SaleCap, uint256 SaleCount, uint256 ChunkSize, uint256 SalePrice){
return(sSBlock, sEBlock, sCap, sTot, sChunk, sPrice);