0

I'd like to write a smart contract that holds X funds, and when a certain condition is met on-chain, transfers them to a predefined address, paying for gas from the contract balance.

Is it possible for a smart contract to "self execute" in this manner?

If not, is it possible to set a limit on how much gas the user (web3 wallet) pays, with the remainder (or all) coming from the smart contract balance?

I figure the solution lies in having a second "helper" contract that calls the main contract and pays for the gas - but how can I set that helper contract to execute automatically on a regular basis?

1
  • Not possible to have self execute. There are some people do it for you and they are called keepers . Chain link has it’s own trusted keeper network that trigger contract for you but u need to read more about it and add interface and code in your contract
    – Majd TL
    Commented Jan 30, 2022 at 18:57

1 Answer 1

1

You can look into OpenZeppelin's Defender and set Autotasks, according to their doucmentation:

The Defender Autotasks service allows you to run code snippets on a regular basis, via webhooks, or in response to a transaction. Thanks to tight integration to Relay and Sentinels, you can use Autotasks to automate regular actions by easily sending transactions or reacting to events from your contracts.

I think this will serve you to self execute, since onced configured they run on their own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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