this is my Solidity code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
// pragma solidity ^0.8.0;
// pragma solidity >=0.8.0 <0.9.0;
contract SimpleStorage {
uint256 favoriteNumber;
struct People {
uint256 favoriteNumber;
string name;
}
// uint256[] public anArray;
People[] public people;
mapping(string => uint256) public nameToFavoriteNumber;
function store(uint256 _favoriteNumber) public {
favoriteNumber = _favoriteNumber;
}
function retrieve() public view returns (uint256) {
return favoriteNumber;
}
function addPerson(string memory _name, uint256 _favoriteNumber) public {
people.push(People(_favoriteNumber, _name));
nameToFavoriteNumber[_name] = _favoriteNumber;
}
}
and this is my deploy.js
const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");
const wallet = new ethers.Wallet(
"0x489c469db7e6049896d646f6233942fb0c5b2b348aed3965ce52e0517587689f",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Contract is deploying please wait...");
const contract = await contractFactory.deploy();
console.log(contract);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
I am getting the following error
info: {
error: {
message: 'VM Exception while processing transaction: invalid opcode',
stack: 'RuntimeError: VM Exception while processing transaction: invalid opcode\n' +
' at exactimate (C:\\Program Files\\WindowsApps\\GanacheUI_2.7.1.0_x64__rb4352f0jd4m2\\app\\resources\\static\\node\\node_modules\\ganache\\dist\\node\\1.js:2:182136)',
code: -32000,
name: 'RuntimeError',
data: [Object]
},
payload: {
method: 'eth_estimateGas',
params: [Array],
id: 4,
jsonrpc: '2.0'
}
}
}
What can be the solution?