Skip to content

Instantly share code, notes, and snippets.

@jessgusclark
Last active August 10, 2021 13:50
Show Gist options
  • Save jessgusclark/f92aa10c2d0f0ca228a04360074bebea to your computer and use it in GitHub Desktop.
Save jessgusclark/f92aa10c2d0f0ca228a04360074bebea to your computer and use it in GitHub Desktop.
Metamask wallet_addEthereumChain and wallet_watchAsset
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>
)
@BananaNeil
Copy link

BananaNeil commented Aug 1, 2021

You're missing a closing quote on the word Success, and you have one too many closing parens after your catch. ;)

@jessgusclark
Copy link
Author

@BananaNeil, thanks for the catch! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment