Is there a way for smart contracts to directly execute a line of code after a set amount of time instead of locking the funds and having the user withdrawal from this escrow contract?

Say I want to delay the transfer of an ERC20 by 1 day, could I do this without an escrow?

  • crontabs are not supported in Ethereum. You have to runn your job periodically from the outside. Neither there is any equivalent of javascript's setTimeout()
    – Nulik
    Commented Jul 21, 2021 at 7:41

1 Answer 1


No, a smart contract cannot execute a function by itself. Someone has to send a transaction that will trigger the particular function that you want to be triggered.

However, it is possible to make a function executable by a transaction only after a certain amount of time has passed or an event has happened. It is also possible to subscribe to services that will send the transaction for you based on a schedule. See my other answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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