Can v have a smart contract function which keeps on running till a condition is met.

Say for example I have a smart contract with one owner address and there is a function called A()

And i am calling this function A from the node. Now the control should be in this function till the address the owner node is greater than 10 ethers

Comments

  • astroastro Member Posts: 16
    Methods in contracts don't continually run, they execute when they are triggered via a transaction. A continually running contract would be seen as an attack on the network given its consumption of resources. Essentially, the gas limit for execution would be reached and the execution would be reverted.
  • trial2trytrial2try Member Posts: 9
    I know recursive calling exhausts the gas, my question is that how can i make the function not exit till a condition is met. Something like stop() in thread
  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    @trial2try So effectively you want while (!x) {//do something}. This will simply consume gas until the gas blocklimit (5000000) is hit and then throw reverting any changes that were made.

    The whole point of gas is to ensure that code stops running.
Sign In or Register to comment.