2

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);
    upgraded.setCompleted(last_completed_migration);
  }
}

Migrations.sol

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

   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 '19 at 5:01
  • i use Ganache 2.0.1 and i think it support constantinoples opcodes – Samaritain Sims Jun 22 '19 at 13:01
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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