Error: Internal JSON-RPC error

I’m getting the following error:

Error: Internal JSON-RPC error.
    at getEthJsonRpcError (errors.js?b80e:118:1)
    at Object.internal (errors.js?b80e:28:1)
    at provider.sendAsync (baseControllers.esm.js?d94b:447:13)
    at async provider.request (baseControllers.esm.js?d94b:469:1)

Product UseCase: I’m using gelato relay with web3auth and gnosis safe to create a flow to buy NFTs using credit cards.

Issue being faced: My flow requires calling the “approve” function on an ERC-20 token, namely USD Coin(PoS) on the polygon Mumbai testnet. More details about the token are as follows: USD Coin (PoS) (USDC) Token Tracker | PolygonScan

However, this contract involves a proxy implementation, which means that many functions like approve have been written in another underlying contract, and function calls are delegated to that contract.

Coming to the issue being faced: Whenever I’m calling any write functions, like approve, on this token using my web3auth signer, I’m getting the mentioned Internal JSON-RPC error.

However, this error is not being faced if I login on web3auth using metamask. This error only arises when I login using a method that comprises of an EOA being created by Web3auth.

Also note that:

  1. All types of calls on simple non-proxy contracts are working perfectly.
  2. Read calls like balanceOf are also working fine, regardless of the login method.

My hunch is that web3auth EOAs are facing an error in gas limit estimation or function calling for proxy contracts.

I have a project submission tomorrow, and am thus running on a crunched timeline. Looking forward to a resolution asap @shahbaz @yashovardhan

  • SDK Version: web3auth/modal": “4.2.3”
  • Platform: Web - Chrome
  • Browser Console Screenshots:

Please provide the Web3Auth initialization and login code snippet below:
I’m using Gelato’s gasless wallet SDK, which has an integration of web3auth web modal in it.

const gaslessWalletConfig = { apiKey: process.env.NEXT_PUBLIC_GASLESSWALLET_KEY};
      const loginConfig = {
        domains: ["http://localhost:3000/"],
        chain : {
          id: 80001,
          rpcUrl: "https://wiser-alien-morning.matic-testnet.discover.quiknode.pro/c2f6cfc05517853e094ad7ea47188326625f20b5/",
        },
        openLogin: {
          redirectUrl: `http://localhost:3000/`,
        },
      };
      const gaslessOnboarding = new GaslessOnboarding(
        loginConfig,
        gaslessWalletConfig
      );
      
      await gaslessOnboarding.init();
      const web3AP = await gaslessOnboarding.login();
      setWeb3AuthProvider(web3AP);

Hey @yajassardana1

Have you tried passing a different rpcUrl endpoint? And what happens if you don’t pass the rpcUrl?

Hello @shahbaz, this rpcURL is one that I’ve created using my quicknode account.

I tried passing other rpcURLs and faced the same issue.

Also, rpcURL is a required parameter here, so not passing it gives an error in initializing the modal.

Furthermore, if I login on the modal using metamask, its working completely fine. Its the other methods which are producing this error.

Any updates @shahbaz @yashovardhan ?

Which SDK is this? And what’s GaslessOnboarding?

@shahbaz i get the same error when doing a send call on smart contract.
this.web3auth = new Web3Auth({ clientId: envVars.web3ClientId, chainConfig: { chainNamespace: 'eip155', chainId: '0x13881', // hex of 80001, polygon testnet rpcTarget: 'https://rpc.ankr.com/polygon_mumbai', displayName: 'Polygon Mumbai Testnet', blockExplorer: 'https://mumbai.polygonscan.com/', ticker: 'MATIC', tickerName: 'Matic', }, uiConfig: { theme: 'light', loginMethodsOrder: ['facebook', 'google', 'twitter'], defaultLanguage: 'en', appLogo: '', // Your App Logo Here }, web3AuthNetwork: 'testnet', });

this is my config

Hey @arpita

When accessing https://rpc.ankr.com/polygon_mumbai, it is important to note that the endpoint can become congested. To reduce this issue, consider utilizing a custom RPC provider from Infura, QuickNode, Alchemy, or other similar services.

Any updates on this issue?

I noticed a similar issue in my code.

Create a contract

    const contract = new ethers.Contract(
        contractAddress,
        contractAbi,
        signer
      );

Calling a method

        const res = await contract.buyTicket(
          quantity,
          referral,
          username,
          signature,
          {
            gasLimit: 1500000,
          }
        );

This works perfectly with Metamask
However, when I connect with a Social login - Google, it fails saying

Error: Internal JSON-RPC error.
    at getEthJsonRpcError (errors.js:118:1)
    at Object.internal (errors.js:28:1)
    at provider.sendAsync (baseControllers.esm.js:443:13)
    at async provider.request (baseControllers.esm.js:465:1)

This does not reach or reflect on the blockchain

If I remove the gasLimit override
The transaction reaches the blockchain but fails as gasLimit is exceeded

Gas Limit & Usage by Txn:

1,249,951 | 1,249,951 (100%)

Gas Limit does not accept a custom value higher than 100000 with Web3Auth social

But I need to set a high limit for my function call.

Is there anything I can do here?
@shahbaz
@chai
@archit

Thanks

Pls specify the value to override as gas and not gasLimit

example:

const res = await contract.buyTicket(
          quantity,
          referral,
          username,
          signature,
          {
            gas: 1500000,
          }
        );

No luck,
Got this in my console

Error: cannot override "gas" (operation="overrides", overrides=["gas"], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)
    at Logger.makeError (index.js:224:1)
    at Logger.throwError (index.js:233:1)
    at eval (index.js:207:1)
    at Generator.next (<anonymous>)
    at fulfilled (index.js:5:43)

Ethers Docs

Fixed this and released 6.1.5

Thanks @chai ,
I see it reflected on GitHub, however, can you publish it to npm as it still shows 6.1.4

NPM

Not all sub packages are published for 6.1.5.
Only wallet-connect-v2-adapter, ethereum-provider, ui, modal packages are required to be updated

Packages I use include:
@web3auth/base”,
@web3auth/coinbase-adapter”,
@web3auth/metamask-adapter”,
@web3auth/no-modal”,
@web3auth/openlogin-adapter”,
@web3auth/torus-evm-adapter”,
@web3auth/torus-wallet-connector-plugin”,
@web3auth/wallet-connect-v2-adapter”,

Which would mean only wallet-connect-v2-adapter gets updated right? @chai

I see…in your case, gelato has to upgrade the modal sdk in their package.
You can contact them to do it

Hi @chai
I am not using any gelato package in my application
But had a similar issue with setting a custom gas limit

pls upgrade and it should just work then