in React component I want to read function "paused" in contract deployed on Rinkeby testnet. Using useDapp (https://usedapp.io/) hook "useContractCall", i call contract function in custom hook:
import { ethers } from "ethers";
import { useContractCall } from "@usedapp/core";
import { contractAddress } from '../../index.js'
const iface = new ethers.Interface([
"function paused()"
]);
export function usePaused() {
const [paused] = useContractCall({
abi: iface,
address: contractAddress,
method: 'paused',
args: [],
}) ?? [];
return paused;
}
It throws an error TypeError: ethers__WEBPACK_IMPORTED_MODULE_0__.ethers.utils.Interface is not a constructor
When instead of
const iface = new ethers.Interface([
"function paused()"
]);
I use const iface = new ethers.Interface(abi);
, my custom hook still doesn't work, it throws warning:
Invalid contract call: address=0x...contract_address... method=paused args=
at RenderButton (http://localhost:3001/static/js/main.chunk.js:1961:70)
What am i doing wrong? I followed instructions on https://usedapp.readthedocs.io/en/latest/guide.html#custom-hooks.