This repository was archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Will burn gas on mainnet #1
Copy link
Copy link
Open
Description
Он не запрещает отправить транзакцию на мейннете, но там нет такого контракта - транзакция упадет и потратит газ.
Можно сделать вот так, переключать автоматически на ринкеби:
const provider = window.ethereum
if (provider) {
const chainId = parseInt(4)
try {
await provider.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: `0x${parseInt(4).toString(16)}`,
chainName: 'Rinkeby Test Network',
nativeCurrency: {
name: 'ETH',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: [RPC_URL],
blockExplorerUrls: [`https://rinkeby.etherscan.io`],
},
],
})
return true
} catch (error) {
console.error('Failed to setup the network in Metamask:', error)
return false
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels