1

I am migrating our dApp from using an older version of web3modal to wagmi. We were using our contracts like this

export const dummyFunctionWrapper = async (
  providerOrSigner: providers.Provider | providers.Signer,
  contractAddress: string,
  meTokenAddress: string,
  amountBurned: BigNumber,
  senderAddress: string,
): Promise<BigNumber> => {
  const abi = new utils.Interface([
    "function dummyFunction(address, uint256, address) external view returns (uint256)",
  ]);
  const dummyContract = new Contract(contractAddress, abi, providerOrSigner);
  return await dummyContract.dummyFunction(meTokenAddress, amountBurned, senderAddress);
};

We can then use these functions in in any component we want, even in useEffects.

Now when migrating to Wagmi, when I instantiate contract with the provider from useProvider or signer from useSigner hooks, I get the following error:

Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https‍://links.ethers.org/v5-errors-CALL_EXCEPTION ]
(data="0x", transaction={"from":"0x791dEaA46a54ab16939b889c74E4cCCBb4Ab095d","to":"0xBdC97D61E8198880c966716df8613cb2fE073D90","data":"0xb9aa404a00000000000000000000000028cd1019bc54c7cff0192f7c60cdf0a4f0c898f30000000000000000000000000000000000000000000000000000000000000000","accessList":null}, error={"code":-32000,"message":"execution reverted"}, code=CALL_EXCEPTION, version=providers/5.7.2)

I checked useContractRead hook but that doesn't work either as I need to use these functions in useEffects.

I have tried using provider and signer from useProivder and useSigner hooks from Wagmi.

Both give me the same sort of error.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tajammul
  • 9
  • 3
  • Update: I also tried using useContract hook from wagmi, it is throwing the same error. I have double checked the contract address it is correct. No further ideas. – Tajammul May 17 '23 at 05:35
  • Update: The error is thrown from smart contracts. Upon further research and debugging I found that there could be one of these reasons; either the contract address is not correct, abi has a function that does not exist in the contract, one or more argument passed to the function is incorrect. In my case it was the third issue. – Tajammul May 19 '23 at 06:38

0 Answers0