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.