An error occurs when truffle migrate try to deploy Migrations.sol contract, i don't understand why

pragma solidity >=0.4.21 <0.6.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  constructor() public {
    owner = msg.sender;

  modifier restricted() {
    if (msg.sender == owner) _;

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);



   Deploying 'Migrations'
Error: Error: Error:  *** Deployment Failed ***

"Migrations" hit an invalid opcode while deploying. Try:
   * Verifying that your constructor params satisfy all assert conditions.
   * Verifying your constructor code doesn't access an array out of bounds.
   * Adding reason strings to your assert statements.

    at Object.run (C:\Users\Sim'S\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.21 (core: 5.0.21)
Node v10.15.3

Error message

  • What version of solc are you using? Does your blockchain support constantinople opcodes? Recent verions of solc 0.5.xx by default require constantinople opcodes and deployment might fail if your blockchain doesn't have support for them.
    – Ismael
    Jun 21, 2019 at 5:01
  • i use Ganache 2.0.1 and i think it support constantinoples opcodes Jun 22, 2019 at 13:01
  • This answer here solved the problem for me.
    – Naveed Ali
    Jul 21, 2023 at 6:15

4 Answers 4


Just ran into the same error. I was running an older version of ganache-cli in this case and had to update ganache, so what helped was running

npm install -g ganache-cli

in my case.


After doing lots of research I found out that updating the truffle version would fix this issue.

npm install -g truffle


Downgrading solc from 0.8.20 to 0.8.13 resolved the problem for me.

I got to that version by downloading the metacoin truffle box, verifying that migration works and then getting the version of solc from the truffle-config.js of the project.

It is worth doing the same, rather than using the specific solc version that resolved this for me at this point in time, as Truffle will probably update the metacoin box eventually to keep up with the rest of their tools and this number will get out of date.

Downloading the metacoin truffle box is as easy as this:

truffle unbox metacoin [PATH/TO/DIRECTORY]


It seems the new version of ganache GUI(at this moment) does not support 0.8.21 instructions. As the answers said I tried to downgrade the version of Solc. but it didn't work. I found out we should clear the build folder to compile contracts again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.