Skip to main content
You can also choose to have your function pay the fee during executions. It must be remembered that running Web3 Functions has computational costs. Please see here the Free Tier limits, in the case that the Web3 Functions goes above these limits, Gas Tank will be also required to pay for the computational costs. This can be done by inheriting AutomateReady.
contract CounterWT is AutomateReady {
    uint256 public count;
    uint256 public lastExecuted;

    constructor(address _automate, address _taskCreator)
        AutomateReady(_automate, _taskCreator)
    {}

    receive() external payable {}

    function increaseCount(uint256 amount) external onlyDedicatedMsgSender {
        count += amount;
        lastExecuted = block.timestamp;

        (uint256 fee, address feeToken) = _getFeeDetails();

        _transfer(fee, feeToken);
    }
}
In the increaseCount function, we use _transfer inherited from AutomateReady to pay Gelato. _transfer has two parameters, fee and feeToken which has to be queried from the Automate contract by using getFeeDetails() To create a task that pays for itself, head over to the task properties and enable the ‘Transaction pays itself’ Transaction Pays Itself Option
I