Coder Social home page Coder Social logo

Uncaught "TypeError: (intermediate value).data is undefined" calling a contract function with insufficient funds on Polygon about web3.js HOT 7 CLOSED

nicos99 avatar nicos99 commented on May 28, 2024
Uncaught "TypeError: (intermediate value).data is undefined" calling a contract function with insufficient funds on Polygon

from web3.js.

Comments (7)

nicos99 avatar nicos99 commented on May 28, 2024

this fix seems to work

from web3.js.

Muhammad-Altabba avatar Muhammad-Altabba commented on May 28, 2024

Thanks @nicos99 for opening the issue and sharing your findings.
Could you open an MR for this fix?

Also I encourage you to check with web3.js version 4. As version 1 will be deprecated later.
So, could you, please, check with version 4 and share your findings?

from web3.js.

nicos99 avatar nicos99 commented on May 28, 2024

ok, I'll check with version 4 and open a PR (probably this weekend)

from web3.js.

nicos99 avatar nicos99 commented on May 28, 2024

Then @Muhammad-Altabba it turns out that with version 4.2.2 (from 'https://cdn.jsdelivr.net') there is no problem!
The error object caught is generic (.message: "Internal JSON-RPC error.") but we have access to the data sub objet that gives details I was looking for (.data.message: "err: insufficient funds for gas * price + value: address 0x<HHH...> have <AAA...> want <BBB...> (supplied gas <GGG...>)", the exact message differs slightly between the networks/provider but the structure is identical).

from web3.js.

Muhammad-Altabba avatar Muhammad-Altabba commented on May 28, 2024

Congratulations @nicos99 that version 4 worked with your case.
It is hard to fulfill the different specifications of every network (in your case Polygon). But we try our best 😄 .

Since the issue is not present in web3 v4. I will suggest to close this issue. And for those who use web3 v1, we encourage them to upgrade. Does this work for your case?

from web3.js.

nicos99 avatar nicos99 commented on May 28, 2024

Thank you @Muhammad-Altabba. I've partialy switched to web3 v4 for my dApp and it will require more validation so for now I'm still on 1.x with my fix. I think this protects against other bugs of the same kind (because we are in a scope not protetced by a try/catch so we have to check carefully each fields access) so I'm going to open a PR soon. I suggest you can tag this bug "1.x" and close it if the PR is not merged quikly.

from web3.js.

Muhammad-Altabba avatar Muhammad-Altabba commented on May 28, 2024

Thanks @nicos99 for your understanding, and many thanks for reporting this and trying to fix it on 1.x.

And for those who encounter this issue they can upgrade to version 4.x.

from web3.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.