Insufficient funds when creating transaction using Relay

{
  response: {
    status: 400,
    statusText: 'Bad Request',
    data: {
      message: 'Insufficient funds: 0.048 ETH required but -0.23780863393604 ETH are available.'
    }
  },
  message: 'Request failed with status code 400',
  request: { path: '/txs', method: 'POST' }
}

Above mentioned error is received when trying to make a transaction through the Relay on Goerli test network. (usually works but error is thrown often at unpredictable intervals).

Official docs say " Relayers on the Goerli and Rinkeby networks will be automatically funded with test ETH upon creation, and will be topped up when they run low on funds."
(https://docs.openzeppelin.com/defender/relay)

Ideally the relay should not run out of gas.

:computer: Environment

Openzepplin Relay (Goerli test network)

:memo:Details

:1234: Code to reproduce

import {
  DefenderRelaySigner,
  DefenderRelayProvider,
} from "defender-relay-client/lib/ethers";

const relayCredentials = {
    apiKey: getenv.string("RELAY_API_KEY"),
    apiSecret: getenv.string("RELAY_API_SECRET"),
  };

const relayProvider = new DefenderRelayProvider(relayCredentials);
const relaySigner = new DefenderRelaySigner(relayCredentials, relayProvider, {
  speed: "fastest",
});

const contract = new ethers.ContractFactory(
    abi,
    bytecode,
    relaySigner
  ).attach(address);
const tx = await contract.function(params);
1 Like

Hi @akshatcx

Welcome to the community!

Auto funding on Rinkeby is currently not working as the funds on our relayer have depleted. However, Goerli should be working fine. Could you share the URL of the relayer so I can further look into what happened please?

Hey @akshatcx,

As @nami said, we're having problems with the Rinkeby funding, but I'm investigating the underlying issue and seems to be a simple semantics problem.

We're throwing this error for situations in which the transaction cost exceeds the relayer funding and it's expressed like:

Insufficient funds: ${balance} ETH required but ${balance - cost} are available

So my first thought is that the negative is expected, but maybe not correct. We can update but first I'd like to ask you for your relayerId so I can track this more in detail and validate nothing is broken.

Thanks in advance!

Hello, thank you for the prompt reply.

Here is the relay ID: f1a68d1a-f6fd-4be1-9807-2ca8dbbfbd98 (https://defender.openzeppelin.com/#/relay/f1a68d1a-f6fd-4be1-9807-2ca8dbbfbd98)

Should I provide the relay address as well?

Hey @akshatcx

Indeed it's just a semantics problem. Your relayer seems fine.

What I'm just curious about is that you didn't receive the ether, but your relayer address seems to be funded more than once

Am I looking at the correct address? I'd just like to dive more into what happened if you didn't receive the funds.

Best

We have been facing this issue again recently with a similar response.

{
  response: {
    status: 400,
    statusText: 'Bad Request',
    data: {
      message: 'Insufficient funds: 0.016 ETH required but 0.008131134897650748 ETH are available for usage on the account(balance is currently 0.020260486945650748 ETH and the expected cost of all pending transactions is 0.012129352048 ETH).'
    }
  },
  message: 'Request failed with status code 400',
  request: { path: '/txs', method: 'POST' }
}

@ernestognw yes indeed, that's the correct address if it helps you dive more.

I wanted to know if there any delay in topping up the relayers, as we need to make requests at a high frequency. As I can see here the relayer hasn't been topped up for the last 10 days although it is running low on funds.

Hey @sounak, sorry for the late reply.

There's no delay, however, the way we calculate the Insufficient funds is not the same as a getBalance. Actually, we sum gasLimit * gasPrice of every pending transaction, so we reserve the potential balance that might be used in the worst-case scenario.

That's why you may have Insufficient Funds errors while still having some balance in your relayer, it's just insufficient based on what's reserved for future transactions (although these transactions may consume less ether at the very end).

The best way to mitigate is to select an accurate gasLimit. I see you're using only 17% of your gasLimit (eg. this transaction)

Regarding the refill, let me circle it with the team since our funding address went out of funds. I'll get back to you once I have an answer :slight_smile:

Edit: I just talked with the team, and given rinkeby has been deprecated and Goerli funds are highly demanded, we decided to stop the autofunding until we find a reliable source of Goerli ETH.

You can get more Goerli ETH using these resources.

Best

Hey @ernestognw, thanks for the reply.

As I had mentioned we need to make transactions at a very high frequency, so faucets are not sustainable. Is there any other testnet chain where you autofund gas fees?

1 Like

Unfortunately, not at the moment. We may plan to support this on Sepolia when we release it (it's on hold right now), but take this with a grain of salt, we're experiencing pretty much the same problem as you.

The one that has worked for me the most is this one.