fixing the deploy.js

This commit is contained in:
Yohan9206 2025-07-14 00:50:59 +03:00
parent 5690cafb7f
commit 1d551f7624

View file

@ -1,23 +1,11 @@
const { ethers } = require("hardhat"); const { ethers } = require("hardhat");
async function main() { async function main() {
// Connect to local devnet RPC explicitly const [deployer] = await ethers.getSigners();
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
// Get signer from provider console.log("Deploying contracts with the account:", deployer.address);
const [deployer] = await provider.listAccounts().then(accounts =>
accounts.length > 0 ? [provider.getSigner(accounts[0])] : []
);
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 ethers.getContractFactory("Lock", deployer);
const lock = await Lock.deploy(); const lock = await Lock.deploy();
await lock.deployed(); await lock.deployed();