获取““合约”在部署时遇到无效的操作码。”使用 Truffle 部署到 BNB 智能链时

问题描述 投票:0回答:1

我已将 NFT 合约部署到 sepolia 测试网,没有任何问题。我现在正在尝试将合约部署到 BNBtestnet。我遇到了上述错误。这是我的松露配置:


 require('dotenv').config();
 const { GETBLOCK_API_KEY,INFURA_API_KEY, MNEMONIC } = process.env;

 const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {


  networks: {

     development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
     },

    sepolia: {
       provider: () => new HDWalletProvider(MNEMONIC, INFURA_API_KEY),
       network_id: 11155111,       // Goerli's id
      gas: 5500000,
     },

     BNBTestnet: {
      provider: () => new HDWalletProvider(MNEMONIC, `https://data-seed-prebsc-1-s3.binance.org:8545`),
      network_id: 97,       // 
     gas: 5500000,
    },

    BNBMainnet: {
      provider: () => new HDWalletProvider(MNEMONIC, `https://bsc-dataseed.binance.org`),
      network_id: 56,       // 
     gas: 5500000,
    },

  },

  // Set default mocha options here, use special reporters, etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.20",     
    }
  },

  plugins: ['truffle-plugin-verify'],
  api_keys: {
    etherscan: 'BUG238UXURBAF9HE4AAZ68DWAW73PNHI4P',
  },
};


我尝试重新安装 Truffle 并更改 RPC 端点,但都没有帮助。为了看看它是否与测试网有关,我尝试部署到 BNB 智能链,这导致了同样的错误。

deployment solidity smartcontracts truffle migrate
1个回答
0
投票

binance测试链目前不支持solidity版本20,您可以将solidity降级到0.8.19版本

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.