Ethers.js throws other errors then expected by write function and read function works as expected (Solidity custom errors) #3037
Replies: 2 comments 1 reply
-
The The unpredictable gas limit means the transaction will fail and my guess is the unrecognized selector is why it is failing; are you sure you are waiting until the contract is deployed and contacting the correct contract? You can try decompiling yourself contract and make sure the selector exists in the jump table. This is almost certainly caused by an artifact file not being updated, the wrong contract address being used or the contract not being deployed yet (although in this last case, I’d expect a different error, unless telos is selector-aware, but I’m not aware of any chain with such a specific error detection). |
Beta Was this translation helpful? Give feedback.
-
Hey @Fabio-GitHub25 I just came across this issue debugging something on Telos EVM and tracked down the fact that "Transaction reverted: function selector was not recognized" is incorrect and could be any number of revert causes, this error comes from the RPC trying to generate meaningful error responses. My comment in the code (I wrote most of the EVM & RPC) was that I borrowed the logic from hardhat error responses, but in my case the cause was not function selector related so I've removed that incorrect error message and updated the testnet RPC if you want to try again. This error feels familiar so I may have already spoken with you and helped sort it out, but if not feel free to DM me on telegram foflexity and we'll figure it out :). Hopefully this issue can be closed for the ethers folks, I <3 ethers and use it all the time, thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am building a smart contract which is deployed to the telos evm test-network. I am using custom errors in my contract for read and write functions.
Read
Write
If i call the read function from ethers with the following code everything works as expected (i'll receive my custom error with the args)
If I want to call the write method with e.g. 11 as parameter I would expect that I'll receive my created custom error because the given number is to high.
But I get some weird errors
invalid length for gasLimit
,estimateGas: invalid BigNumber string
,cannot estimate gas; transaction may fail or may require manual gas limit
. But If I add the gas limit manually as the error pointed out, I'll get an other error messageTransaction reverted: function selector was not recognized
Ethers.js write action code:
If I change the revert statement in the
setMyNumber
function to a require statement like this, I'll get the expected error and the error reason.I don't understand what I'm missing and I was wondering if there is an known pattern to handle such custom errors in ethers.js
Beta Was this translation helpful? Give feedback.
All reactions