Error Truffle Migrate "VM Exception while processing transaction: invalid opcode"

Viewed 935

I testing Truffle Migrate with project Metacoin and deal with this error.

$ truffle migrate

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



Starting migrations...
======================
> Network name:    'development'
> Network id:      1590824689051
> Block gas limit: 6721975 (0x6691b7)


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

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x7a1e7674deb662dd59e821db7d102795724135c940f118855b5d70abb11ec64e
   > Blocks: 0            Seconds: 0
   > contract address:    0x2C962f16f596B423A2810B4202B09314691e2b16
   > block number:        3
   > block timestamp:     1590824746
   > account:             0xd3a13CEEb9edFE9c0a6437f9ED124AeB5Fac9859
   > balance:             99.85802118
   > gas used:            188483 (0x2e043)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00376966 ETH


   ⠹ Saving migration to chain.
Error: Returned error: VM Exception while processing transaction: invalid opcode
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:93:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:57:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/migration.js:167:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:253:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:218:1
Truffle v5.1.28 (core: 5.1.28)
Node v12.17.0

I tried upgrade version truffle, testrdc, ganeche but it's still error.

$ npm install -g truffle@latest
$ npm install -g ethereumjs-testrpc@latest
$ npm install -g ganache-cli@latest

Pls help me if have any good ideal.

Thanks,

3 Answers

I was also facing the same error when I was launching local blockchain with 'testrpc' command. The error got solved when I used 'ganache-cli' command to launch local blockchain.

This is a long time after the fact, but I just had this problem and it was a mismatch between the compiler evmVersion used for the compile and for the ganache-cli. Ganache was specifying Byzantine, and the compiler was defaulting to something else (Earlier version?)

This solved the problem

npm i -g truffle@v5.0.5
Related