This is my autotask code.
const { DefenderRelayProvider } = require('defender-relay-client/lib/web3');
const Web3 = require('web3');
const ABI =[contract abi]
exports.handler = async function(event) {
const provider = new DefenderRelayProvider(event, { speed: 'fast' });
const web3 = new Web3(provider);
// Use web3 instance for querying or sending txs, for example...
const [from] = await web3.eth.getAccounts();
const contract = new web3.eth.Contract(ABI, "contract address", { from });
await contract.methods.SomeFunction().send(); // very high computation function
}
I made it work so that the SomeFunction will run after 24 hours. Most of the time, the required gas is between 0.5 matic to 0.9 matic. However, since my relayer only has a balance of 5 matic, it gave me an error of insufficient balance.
Error while attempting request: Insufficient funds: 6.1548387823591164 MATIC required but 5.915268962088331684 MATIC are available for usage on the account.
6.15 matic gas is huge, and it's not normal that I'm getting a balance error, given that the average gas for this function is between 0.5 matic to 0.9 matic. When I tried running the function manually, the first attempt gave the same error, but it was successful on the second try.
Can someone please help me with this?