Hooks (useCall & useCalls) not returning data when wallet not connected / wrong network / !window.ethereum
Hooks (useCall & useCalls) not returning data when wallet not connected / wrong network / !window.ethereum. Checking network tab, all RPC calls are 200.
Steps to reproduce:
- Disconnect app in metamask if already connected.
- Refresh app
- useCall & useCalls hook returns undefined or
- Open app in incognito tab.
- useCall & useCalls hook returns undefined
Could you please include a code example?
Could you please include a code example?
function useContractInfo() {
const { value, error } =
useCall({
contract: new Contract(contractAddress, contractInterface),
method: 'getContractInfo',
args: []
}) ?? {};
if (error) {
console.error(error.message);
return {
totalStaked: undefined,
totalRefBonus: undefined,
totalUsers: undefined
};
}
return {
totalStaked: value?.[0],
totalRefBonus: value?.[1],
totalUsers: value?.[2]
};
}
Could you please include a code example?
function useContractInfo() { const { value, error } = useCall({ contract: new Contract(contractAddress, contractInterface), method: 'getContractInfo', args: [] }) ?? {}; if (error) { console.error(error.message); return { totalStaked: undefined, totalRefBonus: undefined, totalUsers: undefined }; } return { totalStaked: value?.[0], totalRefBonus: value?.[1], totalUsers: value?.[2] }; }
I'm thinking you should use codesandbox.com since the example you posted doesn't have the contractAddress, contractInterface variables defined
Ran into the same issue, Check your config and make sure you're importing Mainnet.chainId rather than Mainnet.chainID. the Docs need to be updated.
same issue facing => useCall return value and error undefined. React: v18 usedapp/core: 1.0.0 ethers: 5.5.x
Same issue here too.
Same issue as https://github.com/TrueFiEng/useDApp/issues/725#issuecomment-1110230151.