Paying for your transactions
When Gelato executes your transaction it needs to pay the transaction fees. The fees can be paid in one of two ways:
  1. 1.
    From Gelato Balance
  2. 2.
    Transaction pays for itself

Gelato Balance

This is the easiest option. You simply deposit some tokens into Gelato for each of the network(s) on which you want to execute transactions. Each time an execution occurs, Gelato will deduct the costs from your Gelato Balance to cover the gas costs. In the future we will introduce a small Gelato fee.
If you Gelato Balance is too low to cover the costs of your transaction it will not execute until you top-up your balance. We provide a notification service for you to receive alerts when your balance is running low.

Transaction pays for itself

You can also choose not to pre-deposit funds into your Gelato Account and have your executions pay for themselves.
This can be done by inheriting OpsReady.
OpsReady.sol
1
import {
2
SafeERC20,
3
IERC20
4
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
6
interface IOps {
7
function gelato() external view returns (address payable);
8
}
9
10
abstract contract OpsReady {
11
address public immutable ops;
12
address payable public immutable gelato;
13
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
14
15
constructor(address _ops) {
16
ops = _ops;
17
gelato = IOps(_ops).gelato();
18
}
19
20
modifier onlyOps() {
21
require(msg.sender == ops, "OpsReady: onlyOps");
22
_;
23
}
24
25
function _transfer(uint256 _amount, address _paymentToken) internal {
26
if (_paymentToken == ETH) {
27
(bool success, ) = gelato.call{value: _amount}("");
28
require(success, "_transfer: ETH transfer failed");
29
} else {
30
SafeERC20.safeTransfer(IERC20(_paymentToken), gelato, _amount);
31
}
32
}
33
}
Copied!
The function which will be automated needs to have the ability to pay Gelato whenever executors call it. Below is an example of this function.
1
function increaseCount(uint256 amount) external onlyOps {
2
require(
3
((block.timestamp - lastExecuted) > 180),
4
"Counter: increaseCount: Time not elapsed"
5
);
6
7
uint256 fee;
8
address feeToken;
9
10
(fee, feeToken) = IOps(ops).getFeeDetails();
11
12
_transfer(fee, feeToken);
13
14
count += amount;
15
lastExecuted = block.timestamp;
16
17
}
Copied!
In the increaseCount function, we use _transfer inherited from OpsReady to pay Gelato.
_transfer has two parameters, fee and feeToken which has to be queried from the Ops contract by using getFeeDetails()
feeToken is set when creating your task on the Gelato Ops UI.