We changed our privacy policy. Read more.
3

Use wallet_addEthereumChain method - https://docs.metamask.io/guide/rpc-api.html#other-rpc-methods Example code: window.ethereum.request({ method: 'wallet_addEthereumChain', params: [{ chainId: '0x38', chainName: 'Binance Smart Chain', nativeCurrency: { name: 'Binance Coin', symbol: 'BNB', decimals: 18 }, rpcUrls: ['https://bsc-dataseed.binance....


2

Alright I figured it out. I was not connected on my localhost ganache server, but the main ethereum one. Just needed to create my custom local server in metamask and everything works well now. The code itself is correct and now I get 5777 as a network id. In case other newbies like myself would stumble upon same problem, I solved it this way: Click on the ...


1

No harm, you can always add it back. This is just the standard local development url.


Only top voted, non community-wiki answers of a minimum length are eligible