0

I have created a smart contract that expects to receive ether via Etherum Wallet desktop app or MyEtherWallet site. The contract then sends equivalent amount of tokens to the ether sender on the same transaction/immediately.

Is it possible to alter the contract code to send the tokens after 6 blocks from the current transaction?

2

smart contracts in Ethereum are reactive, not proactive. In other words, they need to be "woken up" by a transaction / method call in order to do be activated. So no self-contained code in your smart contract can do what you want. However, you still have 2 options:

  • fire an event in response to the reception of ether; then have a service (e.g. written in node.js with web3) listening to the event, counting 6 new blocks from it and then triggering the token transaction method on the smart contract. Keep in mind that there is no guarantee that the transaction will be accepted in the next block anyway, so it's more like 6+ blocks.

  • Use some sort of alarm service like Ethereum alarm clock that will do it for you (for a fee).

| improve this answer | |

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