1

I am new to solidity and to smart contracts, i couldn't find a great resource describing how the execution of a function in the future really work behind the scenes and how to implement it. I'd appreciate any help

0

It's not possible to schedule a future execution from Solidity.

However, its possible to schedule a future execution from outside Ethereum. For example, you could use an external system like Ethereum Alarm Clock to schedule a future execution. It will also require you to add a certain interface (function) in your smart contract to be compatible with the Ethereum Alarm Clock.

| improve this answer | |
0

This functionality is not possible natively in ethereum, you need to use external services like Oraclize, Aion scheduling System or EAC.

This answer shows a list of the available services with pros and cons: How can a contract run itself at a later time?

Hope this helps

| improve this answer | |
0

You can create a timestamp or block.number dependent function in solidity.

But you still have to activate it from an outside transaction when you want it execute at the time of or time after.

What that would look like is the following in pseudo code.

// in your function body
if(blockOrTimeReached()) {
    doScheduledTask()
}

Or it could be a modifier placed upon that function.

modifier checkScheduled() {
    if(blockOrTimeReached()) {
        doScheduledTask()
    }
    _;

}

function simpleTask() public checkScheduled returns (uint256) {
    // code here
}

This, of course, is highly dependent on your use-case.

| improve this answer | |

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