Closed menarayanzshrestha closed 1 year ago
I solved by following steps:
packages used:
{
"dependencies": {
"dotenv": "^16.3.1",
"ethers": "5.7.2",
"fs-extra": "^11.1.1",
"solc": "^0.8.20"
},
"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
}
}
final code converted to
const { getDefaultProvider, Wallet, ContractFactory } = require("ethers")
const fs = require("fs-extra")
require("dotenv").config()
async function main() {
let provider = getDefaultProvider(process.env.RPC_URL)
let wallet = new Wallet(process.env.PRIVATE_KEY, provider)
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8")
const binary = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin", "utf8")
const contractFactory = new ContractFactory(abi, binary, wallet)
console.log("Deploying, please wait...")
// const contract = await contractFactory.deploy({ gasPrice: 110000, gasLimit: 200000000 })
const contract = await contractFactory.deploy({ gasPrice: 100000000000, gasLimit: 1000000 })
console.log(contract)
const deploymentReceipt = await contract.deployTransaction.wait(1);
console.log(deploymentReceipt);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
I am following the same as tutorials but facing problem while deploying into Ganache locally
Code to deploy I am using is:
when I try to deploy this file with command "node deploy.js"
It says
Version I am using is