Skip to content
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

MetaMask - RPC Error: missing value for required argument 1 #173

Open
njaindeqode opened this issue Dec 13, 2021 · 11 comments
Open

MetaMask - RPC Error: missing value for required argument 1 #173

njaindeqode opened this issue Dec 13, 2021 · 11 comments

Comments

@njaindeqode
Copy link

  <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
@cdric
Copy link

cdric commented Dec 19, 2021

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

@WissenIstNacht
Copy link
Contributor

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],
},

@softwaredev927
Copy link

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

@WissenIstNacht
Copy link
Contributor

WissenIstNacht commented Jan 14, 2022

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

@ihorbond
Copy link

ihorbond commented Jan 26, 2022

@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
Copy link

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

@andrewaarestad
Copy link

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],
              }
            }}>

@siddharth-prajapati
Copy link

siddharth-prajapati commented Mar 2, 2022

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

@albsa
Copy link

albsa commented Jun 15, 2022

Any update on this?

@TheLoneDeveloper
Copy link

Same issue here

image

image

Is there still no fix for this?

@albsa
Copy link

albsa commented Jul 23, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants