use-wallet icon indicating copy to clipboard operation
use-wallet copied to clipboard

MetaMask - RPC Error: missing value for required argument 1

Open njaindeqode opened this issue 2 years ago โ€ข 11 comments

  <UseWalletProvider
      chainId={4}
      connectors={{
        injected: {},
        walletconnect: {
          rpcUrl:
            "rinkby rpc url ",
        },
      }}
    >
    
    - Whenever clicking on the connect button metamask gets connected but it shows MetaMask - RPC Error: missing value for required argument 1  error in the console.log

njaindeqode avatar Dec 13 '21 12:12 njaindeqode

Currently into the same issue. Have you figured it out @njaindeqode ?

cdric avatar Dec 19 '21 07:12 cdric

Hey everyone ๐Ÿ‘‹๐Ÿผ

This is no longer the right way to pass arguments to the provider. In particular, the provider no longer accepts the argument chainId. You now have to pass the id as part of each connector you want to use.

The reason for this is that you can tell useWallet to be be aware of several networks at the same time. WIth Metamask, for example, this allows you to change the network in your wallet. Network changes will then be picked up and reflected by useWallet.

For that to work, you can set the injected connector as follows:

injected: {
  chainId: [1, 4],
},

WissenIstNacht avatar Dec 20 '21 20:12 WissenIstNacht

@WissenIstNacht I followed your way but still getting this error, can you help me please?

softwaredev927 avatar Jan 13 '22 17:01 softwaredev927

Hey, could you share the code snippet where you call the context provider? Something like OP did in the first comment.

WissenIstNacht avatar Jan 14 '22 11:01 WissenIstNacht

@lclement927 you probably didn't wrap it in connectors <UseWalletProvider autoConnect connectors={{ injected:{ chainId: [1] } }} > @WissenIstNacht would be a good idea to update the API section in the doc as it still lists chainId

ihorbond avatar Jan 26 '22 03:01 ihorbond

@WissenIstNacht but with this config connect() doesn't seem to work anymore.

ihorbond avatar Jan 26 '22 04:01 ihorbond

I'm still seeing the MetaMask RPC Error: missing value for required argument 1, and I'm not using the chainId prop:

          <UseWalletProvider
            autoConnect={true}
            pollBalanceInterval={10000}
            pollBlockNumberInterval={10000}
            connectors={{
              injected: {
                //allows you to connect and switch between mainnet and rinkeby within Metamask.
                chainId: [1, 4, 1337],
              }
            }}>

andrewaarestad avatar Feb 21 '22 18:02 andrewaarestad

i am also getting same error connectors={{ injected: { chainId: chains, },

siddharth-prajapati avatar Mar 02 '22 12:03 siddharth-prajapati

Any update on this?

albsa avatar Jun 15 '22 08:06 albsa

Same issue here

image

image

Is there still no fix for this?

TheLoneDeveloper avatar Jun 17 '22 21:06 TheLoneDeveloper

I got it fixed by making a patch for 0.13.4 Follow the steps from https://www.mariokandut.com/how-to-patch-an-npm-dependency/#use-patch-package to apply the patch.

  • Skip the first part, as I already made the patch file.
  • Add a patches folder in your root where package.json is located
  • Add the post install script as shown in the link
  • Add the package as dev dependency
  • Reinstall packages with yarn / npm

Download the zip here to find the patch file https://gist.github.com/albsa/97a0b5a5f507db420f9ab6449da705b1

Good luck all

EDIT: If anyone else is interested, I also fixed 0.13.6, removed the image error for people who are using next.js including the metamask error:

https://www.npmjs.com/package/@albs1/use-wallet

albsa avatar Jul 23 '22 11:07 albsa