From my understanding of smart contracts it would seem that there is no way to set a specific function or action to trigger itself after a certain time, is this the case?

Is the only way to allocate unsold tokens to set a function which does so and then call that function manually upon the finish of the ICO end date?

I cannot find any implementation of this kind of thing, but surely it is a common method within ICOs? OpenZeppelins "FinalizeAgent" contract is of no help, as it does not explain how it is triggered.

Thank you.


Have you thought about using a [mintable] token( https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol)? Then there would be no unsold tokens to have to worry about burning 😉

But, if you can't do that.

Then yes, you're correct that a smart contract can't trigger itself to do something as that would require some sort of loop. And could you imagine how screwed the EVM would be if all smart contracts were looping waiting for a time based event to occur? No bueno. Not only that, smart contracts can't pay gas costs (IIRC that's in the works or is an EIP)

Direct answer:

function burnTokens() public onlyOwner onlyCrowdsaleOver {

You are right saying that there's no way to set an action to be triggered after a specific time frame by itself. There needs to be a transaction that does that.

The transaction could trigger a function like this

function burnTokensAfterSale() {
    if (finalized && (block.number > 6000000)) {
        _transfer(0, remainingTokens)

There is the now keyword in ethereum that is equal to a timestamp.

Why don't you use something like:

    if(now > 1500000)
  • But wouldn't that need to be inside of a function that would then be called after the crowdsale has ended? Is calling a function via the owner address the accepted way to implement this? Thanks for your help. Feb 14 '18 at 15:55
  • ethereum.org/crowdsale Look at the example, here the verification is called by a modifier each time a function is called.
    – Betcheg
    Feb 14 '18 at 15:59

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.