javascriptsmartcontractsethers.jserror-messagingwagmi

Uncaught (in promise) ContractFunctionExecutionError with no error message


I'm using Wagmi to submit a transaction to the blockchain, which is probably reverting but, if I run on any browser on my Windows pc, I don't get any error message logged more than the Error class:

Uncaught (in promise) ContractFunctionExecutionError
    at getContractError (getContractError.js:34:12)
    at simulateContract (simulateContract.js:83:98)
    at async simulateContract (simulateContract.js:30:33)
    at async writeContract (writeContract.js:29:46)Caused by: ContractFunctionZeroDataError
    at eval (getContractError.js:22:20)
    at getContractError (getContractError.js:33:7)
    at simulateContract (simulateContract.js:83:98)
    at async simulateContract (simulateContract.js:30:33)
    at async writeContract (writeContract.js:29:46)

The strange part is that, when if I run the EXACT SAME CODE, being hosted on the same Windows pc, on the same browser, but on a Mac, the log is totally different and shows something like:

Uncaught (in promise) ContractFunctionExecutionError: The contract function "approve" returned no data ("0x").
This could be due to any of the following:
  - The contract does not have the function "approve",
  - The parameters passed to the contract function may be invalid, or
  - The address is not a contract.
Contract Call:
  address:   0x**** (some ERC20 contract address)
  function:  approve(address spender, uint256 amount)
  args:             (0x******* , 41700000000000000)
  sender:    0x**** (my wallet address)
Docs: https://viem.sh/docs/contract/simulateContract
Version: viem@2.7.6
    at getContractError (getContractError.js:34:12)
    at simulateContract (simulateContract.js:83:98)
    at async simulateContract (simulateContract.js:30:33)
    at async writeContract (writeContract.js:29:46)
    ... (the rest of the stack trace)

Both errors happens on the same getContractError.js:34 line.

What is going on here? Are my Chrome and Edge on Windows misconfigured to hide Error messages or something? How can I get normal error messages here?

I submitted a bad transaction and expected to get a meaningful error message explaining what I did wrong, but got almost nothing.


Solution

  • I had a slightly different issue with a similar stack trace:

    App.tsx:375 ContractFunctionExecutionError
    at getContractError (getContractError.ts:72:1)
    at readContract (readContract.ts:128:1)
    at async service.ts:100:1
    at async Object.callback (App.tsx:335:1)Caused by: ContractFunctionZeroDataError
    at getContractError.ts:56:1
    at getContractError (getContractError.ts:70:1)
    at readContract (readContract.ts:128:1)
    at async service.ts:100:1
    at async Object.callback (App.tsx:335:1)
    

    Also observed the same log inconsistencies but just on different browsers (chrome vs brave).

    In the end, my issue was just that the value passed into my RPC url variable was not the one where the contract was deployed, and that fixed my issue after correcting it