mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
fixing the deploy.js
This commit is contained in:
parent
5690cafb7f
commit
1d551f7624
1 changed files with 3 additions and 15 deletions
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue