useDApp: "TypeError: Unsupported chain" calling useContractFunction
Hi Team
Great framework. Can’t seem to get past this one, no matter how I try. Fairly new to dApp design, but pretty sure I have everything setup right.
As soon as I call this,
const { state: buyTx, send: buyTest } = useContractFunction(contract, 'test', { transactionName: 'Buy test' });
buyTest();
I receive this via the:
useEffect(() => {
console.log(buyTx);
}, [buyTx]);
You can clearly see the chainId=5 in the screenshot, this is Goerli and I can connect to my wallet OK to get this far.
I should also state, if I change my contract function to buy1 for example,. it crashes stating Unhandled Rejection (TypeError): contractWithSigner[functionName] is not a function so I know it’s communicating to the very simple buy method I have settup in Solidity (currently returning 123 as a uint256).
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (3 by maintainers)
Hey Alex, thanks a lot for your workaround !
It wasn’t working at first on my end because the contract instance wasn’t connect to a signer, had to make some tweaks (also removed chainId as parameter and got it directly from useEthers)
I’ve been having the same issue since yesterday as well. Here’s a workaround that seems to fix the issue. Basically, all we need to do is add the chainId to the result of the contract function.
Hi, i fixed the issue with chainId being equal 0, it’s up in version 0.4.5
Also if anyone needs
useSendTransactionJust got this same error on Ropsten. In my case, it likely has to due with Metamask using EIP-1559 type transactions. Yesterday, it was using Legacy type transactions and working fine.