Last active
August 10, 2021 13:50
-
-
Save jessgusclark/f92aa10c2d0f0ca228a04360074bebea to your computer and use it in GitHub Desktop.
Metamask wallet_addEthereumChain and wallet_watchAsset
This file contains hidden or 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
const addNetwork = () => { | |
const params = [{ | |
chainId: '0x1e', | |
chainName: 'RSK Mainnet', | |
nativeCurrency: { | |
name: 'RSK BTC', | |
symbol: 'RBTC', | |
decimals: 18 | |
}, | |
rpcUrls: ['https://public-node.rsk.co'], | |
blockExplorerUrls: ['https://explorer.rsk.co'] | |
}] | |
window.ethereum.request({ method: 'wallet_addEthereumChain', params }) | |
.then(() => console.log('Success')) | |
.catch((error: Error) => console.log("Error", error.message)) | |
} | |
return ( | |
<button onClick={addNetwork}>Add RSK Mainnet to Metamask</button> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're missing a closing quote on the word
Success
, and you have one too many closing parens after your catch. ;)