I need a smart contract function which executes every 60 seconds

trial2trytrial2try Member Posts: 9
I tired using this

function timer(){
if (now >= 60 seconds){
calledfunction();
}

function calledfunction(){
//code

timer();
}


calledfunction is not being called when i call timer() so i tired calling calledfunction() directly and it also didnt execute. When i commented timer() in calledfunction() and then invoked calledfunction() then the code worked.

Any idea to call a solidity function for every 60 seconds.

Comments

  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    edited June 2016
    @trial2try Contracts need an external initiator so you would have to have a JS function call the contract every 60 seconds rather than the contract trying to call itself, which even if it looped would simply run out of gas.
Sign In or Register to comment.