Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Will burn gas on mainnet #1

Open
caffeinum opened this issue Aug 5, 2021 · 1 comment
Open

Will burn gas on mainnet #1

caffeinum opened this issue Aug 5, 2021 · 1 comment

Comments

@caffeinum
Copy link
Member

https://github.com/buildship-dev/generativeNFT-template/blob/ac3cf4116f0feb656895c9eb5c8d41d5e6f1900b/mint.js#L55

Он не запрещает отправить транзакцию на мейннете, но там нет такого контракта - транзакция упадет и потратит газ.

Можно сделать вот так, переключать автоматически на ринкеби:

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
    }

https://github.com/pancakeswap/pancake-frontend/blob/5bdd4486d3916c6b62b15d38a0a148e44f8089ed/src/utils/wallet.ts#L15

@caffeinum
Copy link
Member Author

Like this:

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant