See eip-3085 and metamask method
For security use chains.json (https://chainid.network/)
const chain = {
chainId: "0x2231c60",
chainName: "Joys Digital Mainnet",
nativeCurrency: {
name: "JOYS",
symbol: "JOYS",
decimals: 18,
},
rpcUrls: ["https://node.joys.digital"],
blockExplorerUrls: ["https://explorer.joys.digital/"],
iconUrls: []
};
window.ethereum
.request({
method: "wallet_addEthereumChain",
params: [chain],
})
.catch((error) => {
console.log(error);
alert(
"An error has occurred. Please make sure the metamask is ready to go. See error in log"
);
});