"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. getting this error how to solve
My migration.sol code
// SPDX-License-Identifier: UNLICENSED //the version of solidity that is compatible pragma solidity ^0.8.0; contract Migrations { address public owner = msg.sender; uint public last_completed_migration; modifier restricted() { require( msg.sender == owner, "This function is restricted to the contract's owner" ); _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } } My truffle config.js file
const path = require("path"); module.exports = { // See <http://truffleframework.com/docs/advanced/configuration> // to customize your Truffle configuration! contracts_build_directory: path.join(__dirname, "/build"), networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*" //Match any network id } }, plugins: ["truffle-contract-size"], compilers: { solc: { version: "^0.8.0" } }, solidity: { version: "0.8.3", settings: { optimizer: { enabled: true, runs: 1000, }, }, }, };