If you have a smart contract function that you need to be called routinely then static jobs are for you!
Say you have a contract that acts as a trust fund that linearly releases funds to be claimed by the beneficiary. This contract contains a public function that will send the available funds to the beneficiary. You can set up a job that will call this function automatically based on an interval that you set. Recognize that frequent executions will cost more gas.
Setting up the job
Your first time setting up a job you will have to register a vault. All static jobs you make will be executed from this vault and you will deposit/withdraw gas for each of your jobs here as well. If the contract you wish to interact with via the static job needs access controls, your registered vault address should be used. You only have to deploy the job vault once per network you publish jobs on.
You will need to know the following to set up the job:
- The chain where the contract is deployed
- The address of the contract
- The desired method to be called
- Any parameters that will be passed into the call
After connecting a wallet with the correct chain selected, you will input the target address. You will be prompted to select the desired method from the contract's ABI (if verified on Etherscan). Proxies will show the implementation's functions and not the proxy functions. After this, if the selected function requires any parameters you will enter the values to use on each call. Please note that these fields will be static. If circumstances change or you would like to change the behavior, the best route is the withdraw the gas for the job and simply create a new job with the correct parameters.
If the values of the parameters need to change or be dynamic, use dynamic jobs instead.
You can now select the frequency of the execution, and fund the job with gas. So long as there is a gas balance for the job, the job will continue to execute. You can effectively pause a job by withdrawing your gas for said job, and refunding the job to unpause.
The job vault you register tracks the gas balance for each job separately, meaning that only funds you delegate for one job will be used for that job. Funds can be withdrawn at any time.