0

I've tried searching for this question but can't seem to find an answer.

There are others asking to auto execute based on an hour interval or other real world check.

What I would like to do is have a contract sitting with an existing balance of ETH watching the balance of another contract. If that balance of contract2 drops below a certain threshold on the next block I'd like contract1 to auto execute a send to bring the balance of contract2 back up.

Basically what I'm asking is if the behaviour of a contract auto evaluates the state of other contracts that it's built to monitor and based on its own logic make a decision to execute a transaction given certain conditions of that contract's state? Does it do that evaluation every block or do I have to build a script to ping infura every few seconds even if there isn't a new block?

0

1 Answer 1

2

Smart contracts can not autoexecute, they should always be triggered by a transaction.

In your case you have a contract A and a contract B. When contract B balance is below a particular values you want contract A to do something. The easiest way to do this is to write a function in contract B to call contract A everytime that contract B is called. Like this A can execute it's work if B balance is below the threshold that you define.

Hope this helps

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