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

Will burn gas on mainnet #1

@caffeinum

Description

@caffeinum

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions