3

I haven't written any contract yet, but would like to know if this is something that can be done. Lets say I write a smart contract to pay someone if his ethereum address goes below a certain amount say less than 1 ether.

I understand the smart contract can detect the amount of funds it has in the account, but the question is does the contract have to continually run/check the addresses balance?

What if I tell the contract to check the balance every 1 day for 365 days? That's 365 gas fee right? And if I pay this fee, doesnt this mean the contract is always on for an entire year? What if I didn't want to check an ether address, but a bitcoin address?

I'm just curious to how ethereum deals with TIME based contracts that requires a condition to be met in the future. I don't understand how this can scale if there are 1000 contracts waiting for a condition to happen. Someone please explain.

0

1 Answer 1

5

If you do want functions within a contract to be automatically triggered then you can use the ethereum alarm clock. Note this is not a core feature of Ethereum but rather a market where people are paid to execute a scheduled call and therefore there is no guarantee that your function will be called.

2
  • so there is no core feature where you can say "run this contract when it reaches block 9929" ? So your saying when you run a contract it will run instantly and not factor in time then? Mar 4, 2016 at 0:16
  • 1
    Contracts are like OOP objects. Their functions only run when they are called. You can say 'only allow this function to be called when it is block 9929 or between 9:30 and 12:00 on the 3rd of march 2018 or whatever' but something needs to call the contract for it to do anything. Or to put it another way there is the concept of time as an immutable global variable but no timers that trigger callbacks. Mar 4, 2016 at 0:31

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