I am writing a contract for an ERC20 token (say ABC). Is it possible to airdrop some of these newly minted ABC tokens to those ERC20 addresses, every time, if they transfer a different token (named BCD) to a particular ERC20 address?


Yes, you can do this. There are two ways to do it:

1) In the transfer function of BCD token, you would check if the transfer is send to the particular erc20 address in question. If the transfer is being made to the desired address, you would call the mint function on ABC token and mint these tokens in the same transaction. The code would look something like:

function transfer(address to, uint value) public returns (bool success) {
    if (to == desiredAddress) {
        ABC(abcAddress).mint(to, value);

2) (If you cannot edit the transfer function of BCD) You can set up an offchain watcher that would view each BCD token transaction. This watcher would watch for each BCD token transfer and perform the ABC mint if it is required. This would cost you, the watcher, each time new ABC is minted.


Option #1 is technically abiding by the ERC20 standard, but it would be hard for other services to integrate the BCD token because of the fact that it may do something unexpected for their service.


BCD contract has already been deployed. I don't have access to its transfer function.

Can you help how to set up an offchain watcher, and implement it's findings in ABC transfer function. Also, there won't be any newly minted ABC, coins will be sent from contract owner address.

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.