0

This question already has an answer here:

There is a function in contract that should call every month. Can this be implemented with the help of Solidity?

For example:

I have made an order for 1 month. A month later the status of the order was changed automatically.

Or every month, the contract variable must increase by 1

marked as duplicate by Ismael, Achala Dissanayake, flygoing, mirg, Rob Hitchens B9lab May 6 '18 at 0:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • ethereum smart contracts' functions are event based, they will never execute if you never trigger them. the easy way is to have a server do the automatic change of your status. – Kaki Master Of Time May 4 '18 at 15:59
0

No, transactions can't be scheduled for the future.

But the examples you gave can be implemented without the need to make an explicit state change. E.g. for the order status:

function createOrder() public {
    creationTime = now;
}

function orderStatus() view returns (OrderStatus) {
    if (now < creationTime + 30 days) {
        return OrderStatus.InProgress;
    } else {
        return OrderStatus.Finished;
    }
}

or for the counter case:

uint256 startTime = now;

function howManyMonths() public view returns (uint256) {
    return (now - startTime) / 30 days;
}

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