Search code examples
tokenblockchainethereumsmartcontractserc20

Can ERC-20 Token be exchanged based on certain event?


I had a quick question about an abnormal ways to buy ERC-20 Tokens and hear if this is technically possible.

Let's assume there is a smart contract that generates and holds ERC-20Token called 'ThankYou' token, which has a supply of 1 billion tokens.

1) User A donates 100ETH to a child in need.

2) Smart contract detects that User A has donated 100 ETH and validates that 100ETH indeed has been sent to the child

3) Smart contract is triggered to send 30ThankYou tokens to User A for doing good.

I would very much appreciate your thought on this. I only came across cases where ERC-20 Tokens are attained by 'buying' with ETH (based on the price of ERC-20 Tokens). I was wondering if above step I mentioned is possible. And If yes, then can User A sell that 30ThankYou tokens for a exchange with ETH.

Thank you,


Solution

  • No, I don't think it is possible for a smart contract to listen for an event.
    You could however write a web application, that would listen for an event and then call the function in your smart contract remotely. But this would have to happen, off blockchain.

    Other than that, you could implement a function askForThanks(), that would check wether or not a user has donated a certain amount of ether in the past and send him ThankYou Tokens accordingly.

    And If yes, then can User A sell that 30ThankYou tokens for a exchange with ETH.

    If people are willing to buy ThankYou Token (although I think that would deminish the whole purpose of your token) you could certainly than trade these Token, like any other ERC20 Token.