[SOLVED] How to solve the transaction underpriced with web3execute function?

Hi,

Polygon gas prices went from 30 to 300 gwei in the past few days and my dapp’s useWeb3ExecuteFunction started giving the “transaction underpriced” error.

From reading other posts here I understood that modifying the gas price is not possible in this function, and so my question is how can I replace this function with the standard ethers function (where I can override the gas prices)?

Because if I use ethers library directly instead of useWeb3ExecuteFunction I have to use my private key to sign the transactions. However, these transactions should be signed by the users, not me.

So how can I let my users sign a transaction with ethers js? Or alternatively, how can I make the useWeb3ExecuteFunction work when the gas prices fluctuate?

P.s. I onboard users with the Web3Auth login and don’t have access to their private keys. And since this login method doesn’t support popups they can’t manually sign their transactions like they would be able with metamask, or can they?

Thank you.

You can look in the sdk code for execute function to see how it is done. You don’t need a private key, the connected wallet application will be used to sign the transaction in front end.

I’ll take a look at it.

That said my execute function is working seamlessly. But the problem is that the execute function gives the “transaction underpriced” error when the gas prices fluctuate (like it is now). And because I can’t edit gas prices with the execute function I’m thinking to change it to a normal transaction function from ethers.js. But in the normal transaction function from ethers.js I have to provide the private key of the signer (which I don’t have because it is my users who sign).

So my questions are:

  1. is there a way to set custom gas prices to web3ExecuteFunction from Moralis SDK?

if not

  1. how can I get the private keys of the users (onboarded via the web3AuthIo) to let them sign their transaction using ethers.js?

or any other workarounds to “Transaction underpriced” error.

Thank you

You don’t need to provide the private key with ethers in front end. That is only an option that can be used in backend.

1 Like

It worked thank you. I used the snippet from setting custom gas section https://v1docs.moralis.io/moralis-dapp/web3/web3#executefunction. The key was tweaking Moralis.enableWeb3 to use web3Auth.

1 Like