I want to connect to ganache and I get an error that I don't know how to solve it. here is my deploy.js code which is script node.js
const ethers = require("ethers")
// const solc = require("solc")
const fs = require("fs-extra")
async function main(){
// const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
// const wallet = new ethers.Wallet(
// "1ef159aa4f7ee5116a0f22652da709ccd8d35827b12a03eb24f22dd023591987",
// provider
// )
let provider = new ethers.providers.JsonRpcProvider("http://0.0.0.0:7545")
let wallet = new ethers.Wallet("34db8b76c03356b47da8e1dcf427a35f9c013ce95a671ce23fe96d86fe2ba44b", 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("Deploying, please wait..");
const contract = await contractFactory.deploy(); // Stop here! wait for contract to be deploy
console.log(contract)
}
main()
.then(() => process.exit(0))
.catch((error)=>{
console.error(error);
process.exit(1);
})
and it produces the following error:
Deploying, please wait..
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
at Logger.makeError (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:233:21)
at Logger.throwError (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:242:20)
at JsonRpcProvider.<anonymous> (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:561:54)
at step (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (/home/stars/forder/blockchain/leson5/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'could not detect network',
code: 'NETWORK_ERROR',
event: 'noNetwork'
}
What am I doing wrong?