Fee payment options

Gelato Account

Paying transaction fees with the Gelato Account is the easiest. Simply deposit any ERC20 tokens that you prefer (only available for Ethereum Mainnet). Every time an execution occurs, your Gelato Account will be charged.

Transaction pays 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 PokeMeReady.
PokeMeReady.sol
1
import {
2
SafeERC20,
3
IERC20
4
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
6
interface IPokeMe {
7
function gelato() external view returns (address payable);
8
}
9
10
abstract contract PokeMeReady {
11
address public immutable pokeMe;
12
address payable public immutable gelato;
13
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
14
15
constructor(address _pokeMe) {
16
pokeMe = _pokeMe;
17
gelato = IPokeMe(_pokeMe).gelato();
18
}
19
20
modifier onlyPokeMe() {
21
require(msg.sender == pokeMe, "PokeMeReady: onlyPokeMe");
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 onlyPokeMe {
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) = IPokeMe(pokeMe).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 PokeMeReady to pay Gelato.
_transfer has two parameters, fee and feeToken which has to be queried from the PokeMe contract by using getFeeDetails()
feeToken is set when creating your task on the Gelato Ops UI.
Last modified 26d ago