web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.35k stars 4.96k forks source link

Internal JSON-RPC error On the ios metamask app #6585

Closed morelearn1990 closed 10 months ago

morelearn1990 commented 1 year ago

I encountered the same problem #7043

Expected behavior

Actual behavior

Steps to reproduce the behavior

  // @ts-expect-error
  if (window.ethereum) {
    // @ts-expect-error
    const web3 = new Web3(window.ethereum);
    const _accounts = await web3.eth.requestAccounts();
    console.log("_accounts", _accounts)
    const erc20 = new web3.eth.Contract(ERC20_ABI, VITE_USDT);
    const balance = await erc20.methods.balanceOf("0x8747E0366aacCeae04c756B471D86d36567c2C5c").call();
    console.log("balance", balance)
  }

balanceOf operation will report an error

Logs

{"name":"ResponseError","code":100,"message":"Returned error: Internal JSON-RPC error.","innerError":{"code":-32603,"message":"Internal JSON-RPC error.","data":{"code":-32000,"message":"execution reverted"}},"data":{"code":-32000,"message":"execution reverted"},"request":null}

Environment

web3.js 4.2.2 metamask ios 7.10.0

morelearn1990 commented 1 year ago

In this issue, switching web3. js to version 1. x is not a problem

morelearn1990 commented 1 year ago

When I compared the parameters passed in to the request, I found that 4. x used input to pass in the parameters, while 1. x used data to pass in the parameters, resulting in an error on the iOS metamask application.

morelearn1990 commented 1 year ago

related #21467

luu-alex commented 1 year ago

Hi there. thanks for submitting this i'll take a look. are u only using metmask through ios?

mconnelly8 commented 11 months ago

Hey @morelearn1990, are you only using metamask through ios?

tauseedzaman commented 10 months ago

Hi there. thanks for submitting this i'll take a look. are u only using metmask through ios?

i am getting the same error on bsc testnet image

morelearn1990 commented 10 months ago

> Hey @morelearn1990, are you only using metamask through ios?

Yes, then I set the value of input and data to be the same together with the metamask to solve this problem, I do not know whether it will cause other problems, at least now no problem!

mconnelly8 commented 10 months ago

Hey @morelearn1990, please check out our latest 4.4.0 release - https://www.npmjs.com/package/web3/v/4.4.0

This issue should already be fixed there. If for some reason you are still seeing this in 4.4.0, please reopen this issue. Thanks.