From 1d551f7624d7f4dac4f47e3be83fda28b86a2978 Mon Sep 17 00:00:00 2001 From: Yohan9206 Date: Mon, 14 Jul 2025 00:50:59 +0300 Subject: [PATCH] fixing the deploy.js --- hardhat/scripts/deploy.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/hardhat/scripts/deploy.js b/hardhat/scripts/deploy.js index e87c0ffd4e..2cc261afcb 100644 --- a/hardhat/scripts/deploy.js +++ b/hardhat/scripts/deploy.js @@ -1,23 +1,11 @@ const { ethers } = require("hardhat"); async function main() { - // Connect to local devnet RPC explicitly - const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545"); + const [deployer] = await ethers.getSigners(); - // Get signer from provider - const [deployer] = await provider.listAccounts().then(accounts => - accounts.length > 0 ? [provider.getSigner(accounts[0])] : [] - ); + console.log("Deploying contracts with the account:", deployer.address); - if (!deployer) { - throw new Error("No accounts found on the devnet."); - } - - console.log("Deploying contracts with the account:", await deployer.getAddress()); - - // Connect contract factory with the deployer signer const Lock = await ethers.getContractFactory("Lock", deployer); - const lock = await Lock.deploy(); await lock.deployed(); @@ -30,4 +18,4 @@ main() .catch(error => { console.error("Deployment failed:", error); process.exit(1); - }); + }); \ No newline at end of file