What if! if the Metamask has no Network, The user wants to works with.He needs to add manually in Metamask.
It may take sometime. By Copy & Paste! by surfing other website and getting details.
Using ChainLink user can add the Network Easily. But Not all time, it won't works!
The Developer will have a query! Then How to I add Programmatically???
Here Comes up with a Solution!
A JavaScript code using Window.Ethereum.
A Program to Connect Polygon Mainnet Easily
const addNetwork = await window.ethereum.request({
method: "wallet_addEthereumChain",
params: [{
chainId: "0x89",
rpcUrls: ["https://polygon-rpc.com/"],
chainName: "Matic Mainnet",
nativeCurrency: {
name: "MATIC",
symbol: "MATIC",
decimals: 18
},
blockExplorerUrls: ["https://polygonscan.com/"]
}]
});
Hope it may useful for Dapp Devs.
Happy Coding!
Top comments (0)