Last active
October 26, 2021 06:26
-
-
Save mainnet-pat/f70885d9f0c828248dbdfea659274dda to your computer and use it in GitHub Desktop.
Add SmartBch to Metamask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paste this in your browser's console window (ctrl + alt + I) | |
try { | |
await window.ethereum.request({ | |
method: 'wallet_switchEthereumChain', | |
params: [{ chainId: '0x2710' }], | |
}); | |
} catch (switchError) { | |
// This error code indicates that the chain has not been added to MetaMask. | |
if (switchError.code === 4902) { | |
try { | |
await window.ethereum.request({ | |
method: 'wallet_addEthereumChain', | |
params: [{ | |
chainId: '0x2710', | |
chainName: 'SmartBch Mainnet', | |
blockExplorerUrls: ['https://www.smartscan.cash/'], | |
rpcUrls: ["https://smartbch.fountainhead.cash/mainnet:8545", "https://smartbch.greyh.at:8545", "https://rpc.uatvo.com:8545"], | |
nativeCurrency: { | |
name: 'BCH', | |
symbol: 'BCH', | |
decimals: 18, | |
}, | |
}], | |
}); | |
} catch (addError) { | |
// handle "add" error | |
} | |
} | |
// handle other "switch" errors | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment