const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
// http://127.0.0.1:7545
// Compile in our code
// Compile them seperately
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");
const wallet = new ethers.Wallet(
"0x578f756dd1e637bb78dff004cff8517f384f3be491cce3147e4a4f53bcbb8396",
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();
console.log(contract);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
The Error is:
JsonRpcProvider failed to `startup; retry in 1s Error: connect ECONNREFUSED 127.0.0.1:7545 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 7545
I thought maybe port 7545 was closed so I ran the netstat command and it seems to be open and listening. I'm a little lost. Any help is much appreciated!