aragon / use-wallet

๐Ÿ‘› useWallet() ยท All-in-one solution to connect a dapp to an Ethereum provider.
MIT License
741 stars 241 forks source link

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

Open njaindeqode opened 2 years ago

njaindeqode commented 2 years ago
  <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 commented 2 years ago

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

WissenIstNacht commented 2 years ago

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 commented 2 years ago

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

WissenIstNacht commented 2 years ago

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

ihorbond commented 2 years ago

@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 commented 2 years ago

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

andrewaarestad commented 2 years ago

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 commented 2 years ago

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

albsa commented 2 years ago

Any update on this?

TheLoneDeveloper commented 2 years ago

Same issue here

image

image

Is there still no fix for this?

albsa commented 2 years ago

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.

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