Open thebuidler opened 2 years ago
I’m having the same issues to be honest and there are variables that unable to validate until the blockchain call is made. I wonder how we can make the error messages more useful as it would be nice to catch them.
That's happens with Kovan, it just throws exception without the error message
I had the exact same error. I'll reproduce the error and then the solution:
I was using a hook
const [amount, setAmount] = useState(0)
and a function to handle input changes
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const newAmount = event.target.value === "" ? Number(0): Number(event.target.value)
setAmount(newAmount)
}
Sending amout as a tx parameter will give you that -32016 error . My solution was to redeclare the hook as
const [amount, setAmount] = useState<number | string | Array<number | string>>(0
and then in the function replace Number(0)
inside the ternary with ""
so it looks like this.
const newAmount = event.target.value === "" ? "" : Number(event.target.value)
I would guess you have some kind of parameter type problem.
Hope it helps.
https://github.com/openethereum/parity-ethereum/issues/10147#issuecomment-462177568
Your exception is probably a kovan exception, which I think might be caused by trying to transfer zero(0) token, so amount should be anything above zero(0). Kovan doesn't go into details about exception, I think it's parity issue.
This is likely not a question for useDApp but truth is I don't know who it falls on (Metamask? ethers.js?), which the question will only reveal further. Hoping someone can give me a quick and straight answer. I have googled this for 30 mins now lol.
I'm submitting a transaction using
useContractFunction
-->send
to Kovan network. I'm able to submit no problem until I hit what I'd expect to be an error within the contract itself. Instead of erroring in the contract, I get a preflight RPC error:For one the code doesn't appear to be a standard exit code as I can't find it anywhere. And two the error is thrown before the user is even prompted to confirm the tx through their MM wallet.
Now, I know what's causing the error. The contract has a
require
check for the error state, but what error is returned and at what stage of the call lifecycle (before the user confirms) have me lost.Thank you!