-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpracticedeploy.js
More file actions
26 lines (24 loc) · 891 Bytes
/
practicedeploy.js
File metadata and controls
26 lines (24 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const ethers = require("ethers");
const fs = require(fs - extra);
require("dotenv").config();
async function main() {
//connecting to the local ganache blockchain
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
//take the abi , bin for deploying the contract
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();
const deployReceipt = await conrtract.deployTransaction.wait(1);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});