I wrote a smart contract to mint some custom tokens using Solidity over Hardhat (Localhost) development environment. The contract compiled successfully but while importing the new minted tokens in my Metamask wallet I got this error message.
I figured out the problem, which was causing the error. The new update for Metamask was not accepting the old RPC for Hardhat(Localhost) = [ http://localhost:8545/ ] and Chain ID = 1337 as shown below >
Error fix :
Go to Metamask > Settings > Networks > Press "Add a network" button > Add these details as shown below >
Network name > Hardhat
New RPC URL > http://127.0.0.1:8545/
Chain ID > 31337 [ Reference Document ]
Currency symbol > HHETH [ Give any symbol you want ! ]
Block explorer URL > [ Optional, so I skipped ! ]
Click on save.
Now open your "hardhat.config.js" in your code editor and update the chainID and network-name according to this snapshot shown below >
Save the "hardhat.config.js" file.
Re-run npx hardhat node in a separate terminal and then run npx hardhat run scripts/deploy.js --network hardhat > shift your Metamask network to the newly created network : Hardhat as shown below >
Now Import Tokens again and you'll see the tokens minted on your wallet.
Happy building :)