From dcfca3c6027c375869e220d4f8e13b0819a4611b Mon Sep 17 00:00:00 2001 From: elieatteah00 Date: Wed, 16 Sep 2026 13:52:51 +0200 Subject: [PATCH] Fail fast with a clear error when no deployer account is configured Running yarn deploy against a network with a missing or misconfigured account (e.g. PRIVATE_KEY not set) currently crashes deep inside hardhat-deploy with "TypeError: Cannot read property 'length' of undefined", which gives no indication of the real problem. Check the deployer account up front and throw a message that says what's actually wrong. Fixes #618 --- deploy/deploy_contracts.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deploy/deploy_contracts.ts b/deploy/deploy_contracts.ts index feb9561e..33ce41fa 100644 --- a/deploy/deploy_contracts.ts +++ b/deploy/deploy_contracts.ts @@ -63,6 +63,14 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { const {deployer} = await getNamedAccounts() // Fetch named accounts from hardhat.config.ts + if (!deployer) { + throw new Error( + `No deployer account configured for network "${hre.network.name}". ` + + "Set the PRIVATE_KEY environment variable, or add an \"accounts\" " + + "entry for this network in hardhat.config.ts." + ) + } + const config = getNetworkConfig(hre.network.name) const contractDeployer = new ContractDeployer(deployer, deployments)