Show wallet Interaction even if wallet has unsufficient funds


I execute a transaction (mint) via .executeFunction. This fails if the wallet has insufficient funds and metamask does not even show a sign screen. I would prefer the screen being shown with the standard message of insufficient funds. Could you please tell me how?


You can use getNativeBalance or getTokenBalances function to get the user’s wallet balance and create an if condition to see if the balance is more than the required balance before calling the executeFunction.

1 Like


You can try to estimate gas of the tranx and check with user balance.

You can use the following code to enable ethersjs provider function.

// Get a (ethers.js) web3Provider 
const web3Provider = await Moralis.enableWeb3();
1 Like

I’m currently facing this issue while using the transfer function of Moralis on version 1.5.9. If a user’s wallet has insufficient funds nothing happens at all. I wasn’t experiencing this on version 0.0.184 .Sadly it has not been solved on this thread.

I’d appreciate if the sign transaction screen shows up with the insufficient balance notice than for nothing to happen at all.


nothing happens, no error in browser console?

The error in browser console says insufficient balance. But the user will not see that error. If there’s a wallet interaction with an insufficient balance notice it will make a lot more sense. Please see attached image.


I don’t understand what that image means, like what you would want to see, or what you see?

if you get a message error, then you can display a pop up with a specific message for example.

The attached image is what I would want to see.

Something has to notify the current user that he has insufficient funds.

is there a way to get that message error from console to display it in the interface somehow?

I’ve been trying to do that unsuccessfully. That would be really helpful.

How are you catching the error in your code? You can show a notification in your frontend from there.

I’m getting the error below on my browser console. I really don’t know how I can display that error on my Html interface.

Uncaught (in promise) Error: insufficient funds for intrinsic transaction cost [ See: ] (error={"message":"err: insufficient funds for transfer: address 0xe... (supplied gas 12510499)","code":-32000}, method="estimateGas", transaction={"from":"0xe...","to":"0x8... ","value":{"type":"BigNumber","hex":"0x10a741a462780000"},"accessList":null}, code=INSUFFICIENT_FUNDS, version=providers/5.6.0)
    at Logger.makeError (moralis.js:42548:21)
    at Logger.throwError (moralis.js:42557:20)
    at checkError (moralis.js:48083:16)
    at Web3Provider.<anonymous> (moralis.js:48647:47)
    at step (moralis.js:48036:23)
    at Object.throw (moralis.js:48017:53)
    at rejected (moralis.js:48009:65)

You can use a try ... catch block and you can handle errors in the catch block

Which Framework are you using for frontend development?
I would also suggest to use a try | catch block and set a variable in the error block.
Example with useEffect() in react:

const [functionExecuteError, setFunctionExecuteError]=useEffect(false)

try{} catch{

then in the code
functionExecuteError &&(<>Minting failed, do you have enough funds in your wallet?</>)

1 Like

I would actually support the request above to be able to show the classical Metamask popup. Users are just used to it. A website build with Moralis should not have do behave differently than all the other websites just using web3 or ethers.

1 Like