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:
- 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 - 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 - 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?