JsonRpcProvider: missing new : Lesson 5 Ethers.js #5047
-
deploy.js codeconst ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
const provider = ethers.providers.JsonRpcProvider("http://127.0.0.1:8545");
const wallet = new ethers.Wallet(
"0x92174bfa0de526c66da8bcf6d1bb701a0acfabf3c9789bb3329729255671a6e8",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf-8"
);
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);
}); ************* Error getting ************baroon@Hacked:~/folder/hh-fcc/ethers-simple-storage$ node deploy.js
JsonRpcProvider: missing new [ See: https://links.ethers.org/v5-errors-MISSING_NEW ] (name="JsonRpcProvider", code=MISSING_NEW, version=providers/5.6.2)
at Logger.makeError (/home/baroon/folder/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (/home/baroon/folder/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:247:20)
at Logger.checkNew (/home/baroon/folder/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/logger/lib/index.js:321:18)
at Object.JsonRpcProvider (/home/baroon/folder/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:448:16)
at main (/home/baroon/folder/hh-fcc/ethers-simple-storage/deploy.js:5:37)
at Object.<anonymous> (/home/baroon/folder/hh-fcc/ethers-simple-storage/deploy.js:24:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
reason: 'missing new',
code: 'MISSING_NEW'
}
baroon@Hacked:~/folder/hh-fcc/ethers-simple-storage$ dependencies{
"dependencies": {
"ethers": "5.6.2",
"fs-extra": "^11.1.0",
"ganache": "^7.7.6",
"solc": "0.8.7-fixed"
},
"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
paulcoffee85
Mar 9, 2023
Replies: 1 comment 1 reply
-
try with placing 'new' in after '=' sign.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
baroonjha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try with placing 'new' in after '=' sign.
const provider = ethers.providers.JsonRpcProvider("http://127.0.0.1:8545");
like this:
const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545");