[VM处理事务时异常:PromiEvent上的操作码无效

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

我创建了一个集成松露和React框架的项目。在编译合同后,我将这些合同迁移到rinkeby或ropsten测试网络。它们很好。但是,当我将这些合同迁移到ganache测试网络时,会出现一些问题,如下所示:

E:\Workspace\WebStormProjects\Ethereum\MusicBlock\client>truffle migrate --network ganache

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'ganache'
> Network id:      5777
> Block gas limit: 0x6691b7


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x7aca328c771f73b0238263749d3a81a73f5fdf38ea826f394dbccbfdc00b9f0e
   > Blocks: 0            Seconds: 0
   > contract address:    0x0422a0813Dc48f53d9c2b845224Bf0ECccb51c82
   > block number:        3
   > block timestamp:     1574923201
   > account:             0x8CcCACB65596b1f5bAc0f0099d7C4fB18495813e
   > balance:             99.85501086
   > gas used:            263741
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00527482 ETH


   ⠙ Saving migration to chain.
Error: Returned error: VM Exception while processing transaction: invalid opcode    at PromiEvent (C:\Users\Lsy\AppData\Roaming\npm\node_mod
ules\truffle\build\webpack:\packages\contract\lib\promievent.js:9:1)
    at TruffleContract.setCompleted (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\execute.js:1
69:1)
    at Migration._deploy (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\migration.js:93:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._load (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\migration.js:57:1)
    at Migration.run (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\migration.js:167:1)
    at Object.runMigrations (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:148:1)
    at Object.runFrom (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.run (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:87:1)
    at runMigrations (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:252:1)
    at C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:217:1
Truffle v5.1.1 (core: 5.1.1)
Node v12.13.0

这是truffle-config.js

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

let secrets;

if (fs.existsSync(path.join(__dirname, "secrets.json"))){
  secrets = JSON.parse(fs.readFileSync(path.join(__dirname, "secrets.json"),'utf8'));
}else{
  console.log("secrets.json doesn't exist!")
}

module.exports = {
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    ganache:{
      host:"127.0.0.1",
      port:7545,
      network_id:"*"
    },
    develop: {
      port: 8545
    },
    rinkeby:{
      provider:()=>{
        return new HDWalletProvider(secrets.mnemonic,"https://rinkeby.infura.io/v3/"+secrets.infuraProjectId);
      },
      network_id:4
    }
    ropsten:{
      provider:()=>{
        return new HDWalletProvider(secrets.mnemonic,"https://ropsten.infura.io/v3/"+secrets.infuraProjectId);
      },
      network_id:3  //3-ropsten 4-rinkeby
    }
  }
};

谁可以帮助我?非常感谢。

reactjs ethereum truffle ganache
1个回答
0
投票

我建议将ganache升级到最新版本reference

npm install -g ganache-cli@latest
© www.soinside.com 2019 - 2024. All rights reserved.