How can I check in the script if my relayer has enough ETH to pay tx fee?

other question, how I can update the script to check if my relayer has enough eth to pay tx fee ?

1 Like

You don’t need to! The Defender Relayer will check that for you, refuse to send the tx unless it has enough funds, and throw an error instead. Also, if your relayer balance drops below 0.1 ETH (we’ll make this value configurable later down the road), you’ll get a notification email reminding you to refill the relayer.

2 Likes

sometimes. I have got this error

" Warning! Error encountered during contract execution [ Out of gas ]"

I can i do change the limit of the gas?

1 Like

Hey @bolo! If you are using ethers.js, it automatically handles gas estimation for you under the hood:

However, it’s possible that ends up being inaccurate due to several reasons. If you run into this error all too often, you can just hardcode the gas limit you want to use by adding an extra gasLimit option to the tx:

const tx = await contract.work({ gasLimit: 3000000 });

The challenge here is figuring out what the gas limit should be, and that will depend on the contract you are calling. Still, remember that any excess gasLimit you set is refunded to you when the tx is mined! Just keep it below the block gas limit.

2 Likes

harvest method as parameter.

the code below is correct?

const tx = await contract.harvest(address, { gasLimit: 3000000 });

1 Like

Hi @bolo,

That looks right based on what @spalladino advised, assuming a harvest function accepting an address parameter and you have set the value in address.

A post was split to a new topic: Check if there any transaction pending before mine