I'm providing a custodial wallet API solution and everything is handled through APIs. The flow looks like this:

1. Client request (tx payload) => MyServerAPI.sendTransaction(tx payload)
2. Where sendTransaction includes two steps:
      a. MyServer => WalletVendorAPI.signTransaction => signedTx => MyServer
      b. MyServer.broadcastSignedTransaction(signedTx)

The wallet balance is 0, how can I cover the gas fee for MyServer.broadcastSignedTransaction?

Potential solutions I tried:

  1. using a provider such as Infura or Alchemy to broadcast signed transaction like provider.sendTransaction(signedTx) but got INSUFFICIENT_FUNDS error since the wallet balance is 0
  2. using OpenZepplin Defender Relayer relayer.sendTransaction({to:"", data:"", ...}), but it only sends the original transaction, doesn't include transaction signing process. I don't have the wallet private key, so I cannot sign the transaction
  3. Also explored meta transaction following example https://docs.openzeppelin.com/defender/guide-metatx, not sure how to plug in a signed transaction string into the meta-tx process. Also, the transaction is signed and broadcasted on my server in one API call, correct me if I'm wrong, but I feel that forwarder is not necessary in my case

I don't have wallet private key, and everything is handled in the backend, aka cannot get user wallet signer from browser, I don't have access to wallet provider or signer. In this case, how to broadcast a signed transaction and cover gas?

1 Answer 1


You're trying to break a protocol level constraint.

MetaTx are indeed signed transactions where the relay is willing to pay for gas. There is no way for the broadcaster to avoid it.

There are a number of methods for the broadcaster to receive compensation. Inexhaustible list:

  1. The contract invoked pays msg.sender - which presumes the receiving contract was crafted for this detail.

  2. Off-chain billing for resources consumed.

  3. Prepaid, on-chain accounting. Simulate the txn, debit the user account (get paid), then relay the package. Don't relay the transaction unless sufficient funds are paid.

Imagine people are paying you to send parcels for them. It might be their name on the paperwork but if the courier (EVM) expects payment before accepting the package then you need to deal with them on their terms.

You can build something in if the destination is under your control, i.e. your contract. For a more generalized solution, how you get paid is a separate concern.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.