-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Uncaught TypeError: o.data.substring is not a function" calling a contract function reverting #4454
Comments
@nicos99 As I explained earlier in issue #3742 this error does not relate to Similarly this issue seems related to |
I hit the same error on Binance Test Chain. After some debugging, I found the o.data returned was somehow an object, not a string: |
@nazarhussain I opened this ticket to explain precisely my problem (the #3742 having a short description) and to give a simpler code example (without relying on MetaMask as you suggested to me). But you are right, the wrongs are shared because the bug does not appear when using I will probably update the description when I test with other clients (latest Ganache, Ropsten, Main net) to help determine the impact. Thank you for your expertise. |
The problem is not Ganache, I'm getting the same problem with Polygon testnet (not using Ganache). |
@sigmaxf @FanM did you manage to solve this issue? Currently I'm having the same as yours. |
I notice using old version of web3 and instantiating the smart contract in frontend fix the issue but I want to use the latest version of web3 and latest instantiation of smart contract. |
I deployed my smart contract using the node of Moralis but still the error still exist. |
I added a type check to work around this. |
@FanM Thanks I look in your work around, clever solution. Thank you. |
I think my issue for now is fixed, my issue in "o.data.substring is not a function" triggers in my ERC20 token contract(MyToken.sol). I change the order of loading of (MyToken.sol) in frontend as the first smart contract that loads and I don't know what happen but the error is gone. Previously (MyToken.sol) is loaded second before my other contract(TokenTimeLock.sol) in asynchronous way. So that is my case. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
…)' to manage revert embedded error details got from some providers like MetaMask (related to issue web3#4454)
…)' to manage revert embedded error details got from some providers like MetaMask (related to issue web3#4454)
…sendTxCallback(err, result)' to better manage revert call reason from some providers like MetaMask (related to issue web3#4454)
Is there an existing issue for this?
Current Behavior
I get an "Uncaught TypeError: o.data.substring is not a function" In the console of my internet browser when I call() a contract function that revert due to an
require
not satified, usinghandleRevert = true
and web3.js version >= 1.2.10 (ok until 1.2.9, still nok with 1.5.2).For instance
rocketContract.methods.SetSpeed(101).call()
with this extract of the contract :function SetSpeed(uint _speedPercent) public { require(_speedPercent <= 100, "speed invalid"); speed = _speedPercent; }
In addition I can not intercept the exception in my code.
Complete call stack with web3.js 1.5.2 :
Expected Behavior
I can catch an exception and get the revert raison. Until version 1.2.9 we get
Returned error: VM Exception while processing transaction: revert speed invalid
using this code :Steps to Reproduce
Web3.js Version
1.5.2
Environment
Anything Else?
There is no issue using web3 as node library. You can find this test script testSpeed.js that demonstrates it (download the file into an empty folder,
npm install web3@1.5.2
in the that folder and thenmocha --timeout 999999 testSpeed
having a live locale Ganache instance).I discovered this bug months ago but I thought it was the #3742.
The text was updated successfully, but these errors were encountered: