Dev Mainnet MetaMask
Full JavaScript code
This code is also available on codesandbox LINK to do
import detectEthereumProvider from "@metamask/detect-provider";
const configure = async () => {
const provider = await detectEthereumProvider({ mustBeMetaMask: true });
if (provider) {
try {
await provider.request({ method: "eth_requestAccounts" });
await provider.request({
method: "wallet_addEthereumChain",
params: [
{
chainId: "0x" + (1111111).toString(16),
chainName: "ParaTon Mainnet",
nativeCurrency: {
name: "PARA",
symbol: "PARA",
decimals: 18
},
rpcUrls: ["https://paraRpc.org"],
blockExplorerUrls: ["https://paraRpcscan.org/"]
}
]
});
} catch (e) {
alert("Error");
console.error("configure provider error", e);
}
} else {
alert("Please install MetaMask");
}
};
export default function App() {
return (
<div className="App">
<button onClick={configure}>Connect</button>
</div>
);
}
Last updated