1

enter image description hereenter image description here

I want to connect local ethereum network to metamask , it says that it need chain id but when i entered the chain id for local node it shows the error "Could not fetch chain ID. Is your RPC URL correct?" I am running geth consol on local pc. What should i do ? thank you

6
  • Can you paste the command you are using to start geth? – Franco Victorio Dec 16 '20 at 18:29
  • geth --port 30303 --networkid 1234 --nodiscover --datadir=$ethereum_home/paradox --rpc --rpcport 8545 --rpccorsdomain "localhost:8000" --allow-insecure-unlock --ethstats paradox:s3cr3t@localhost:3000 --rpcapi "eth,net,web3,personal,miner" – Prasanna Desai Dec 17 '20 at 4:47
  • I tried --rpcorsdomain "*" and also tried to set network id and chain id same. But did not work – Prasanna Desai Dec 17 '20 at 8:19
  • You are starting that local node, and then trying to connect to it from MetaMask? And MetaMask gives you that error? – Franco Victorio Dec 17 '20 at 12:48
  • That is right , I started node and deployed contract on local ethereum , then I went to the front end of that contract to make a transaction and for that transaction to complete i need metamask. so I added custom RPC and it was long before the metamask update back then it worked very well but now it is asking for ChainId and when i am entering , it gives error. I tried both Hex and Decimal value of chainId – Prasanna Desai Dec 17 '20 at 16:17
1

You seem to have started geth with networkid 1234 and then are trying to reach it on id 4224.

Try connecting it to 1234 (or set networkid to 4224 in geth)

1
  • The chainId and networkId are different. – zxq9 May 10 at 8:38
1

SOLVED: I just had to change "localhost" to "127.0.0.1" in RPC url.

0

If you happen to be using Ganache in combination with WSL, then you may have to adjust your settings accordingly:

  • In Ganache, go to Settings => Server
  • In the HOSTNAME dropdown box, select the network interface with (WSL) at the end, e.g. 172.29.64.1 - vEthernet (WSL)
  • Click on the SAVE AND RESTART button

Change your truffle-config.js to reflect the changed IP address, e.g.:

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "172.29.64.1",
      port: 7545,
      network_id: "*" // Match any network id
    },
    develop: {
      port: 8545
    }
  }
};

In Metamask, use the following settings for the Custom RPC:

  • New RPC URL http://172.29.64.1:7545
  • Chain ID 1337

The Chain ID must be set in Metamask and is configured according to this information:

--chainId: Specify the Chain ID ganache-cli will use for eth_chainId RPC and the CHAINID opcode. For legacy reasons, the default is currently 1337 for eth_chainId RPC and 1 for the CHAINID opcode. Setting this flag will align the chainId values. This will be fixed in the next major version of ganache-cli and ganache-core!

Possibly this will change in the future, but at the moment it's the setting that works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.