diff --git a/client/src/constants.js b/client/src/constants.js index 24ccaccbb..477cae031 100644 --- a/client/src/constants.js +++ b/client/src/constants.js @@ -62,7 +62,7 @@ export const NETWORKS_INGAME = { id: "11155111", currencyName: "Sepolia-ETH", currencySymbol: "SEP", - rpcUrl: `https://rpc.sepolia.org`, + rpcUrl: `https://ethereum-sepolia-rpc.publicnode.com`, blockExplorer: "https://sepolia.etherscan.io", explorer: { apiKey: `${process.env.REACT_APP_SEPOLIA_EXPLORER_API_KEY}`, diff --git a/client/src/containers/App.js b/client/src/containers/App.js index fcc48a350..9a11c4272 100644 --- a/client/src/containers/App.js +++ b/client/src/containers/App.js @@ -116,18 +116,21 @@ class App extends React.Component { } catch (switchError) { // This error code indicates that the chain has not been added to MetaMask. if (switchError.code === 4902) { + const sepolia = constants.NETWORKS_INGAME.SEPOLIA; try { await window.ethereum.request({ method: "wallet_addEthereumChain", params: [ { - chainId: [ - { - chainId: `0x${Number( - constants.NETWORKS.SEPOLIA.id - ).toString(16)}`, - }, - ], + chainId: `0x${Number(sepolia.id).toString(16)}`, + chainName: sepolia.name, + rpcUrls: [sepolia.rpcUrl], + nativeCurrency: { + name: sepolia.currencyName, + symbol: sepolia.currencySymbol, + decimals: 18, + }, + blockExplorerUrls: [sepolia.blockExplorer], }, ], });