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

if gasLimit is harcodes, Ether.js will still estimate gas ?

1 Like

Hi @Bolo,

The Ethers code will only estimate a gas limit if you haven’t hardcoded a value for the gas limit.

Is there any update regarding this value being configurable? If not, any suggestion on how to implement this? Can I, somehow use a Sentinel with an Autotask condition for it? AFAIK, I cannot but I was wondering. The only viable way I was thinking is just having an Autotask that rungs every X seconds/minutes and checks the ETH balance of an address and, if it is below some Y threshold, it would notify making an HTTP call to some external service (Sentry for example).
Thanks!

Hi @Fede,

Is there any update regarding this value being configurable

Do you mean the 0.1 eth threshold for the low balance notification?

Yes @dylkil, that threshold. And also about any suggestion if one wants to set a different threshold, like I said in my comment :slight_smile:

It isn't configurable but its an interesting suggestion. You could definitely implement something to do such with an autotask, it all depends on how you want to do it.

If you just want a simple notification but with a new threshold you could do like you suggest, create an autotask with your relayer connected that fires every X seconds/minutes and check the balance of the account, if < than your new threshold send a notification.

If you wanted to keep your relayers topped up automatically you could have a master funding relayer that held all of your funds and then implement an autotask with this master relayer connected to it, loop over all of your existing relayers and transfer them ETH if < your threshold.

1 Like