I have a Erc20 token X and an Smart Contract A

Smart Contract A contains 1000 X Tokens.

How can an User get an defined amount of X Tokens from this Smart Contract? (something like an Airdrop)

So Basically a user should call a method like: getAirdrop() and then should get 100 X tokens from A's wallet

I tried the following:

function getAirdrop(){
    erc20TOken.transferFrom(this, msg.sender, 10000000000000000000);

... and...

function getAirdrop(){
    erc20TOken.increaseApproval(msg.sender, 100000000000000000000);

... but do not work.

  • Might be worth checking out a related question, as well as the source code of Airdropper for inspiration. – S0AndS0 May 23 at 16:52

But how can you be sure, that user has finalized all tasks to get tokens? I assume tokens should be sent manually by owner (or implemented on backend). But also interested in answers with more experience.


If the contract A owns the required tokens you can simply use the transfer function in the ERC20 token contract.

So something like this (assuming you have a reference erc20TOken to the actual token contract):

function getAirdrop() public { 
  erc20TOken.transfer(msg.sender, 100); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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