Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
How is hardhat implicitly knowing deployer address?

I am new to using hardhat and I was trying to figure out how it is working. The documentation seems a little bit fuzzy as there are multiple layers of abstractizations and I don't understand how is the ethers.getSigners() using my private key. Is it implicitly using the hardhat config file defined in the root of my directory? Also is hardhat project structure predefined and enforced? If not, how does getContractFactory know where to look for the artifact?

const { ethers } = require("hardhat");

async function main() {
    const [deployer] = await ethers.getSigners();
    console.log("Account balance:", (await deployer.getBalance()).toString());

    const VendingMachine = await ethers.getContractFactory("VendingMachine")
    const vendingMachine = await VendingMachine.deploy()
    await vendingMachine.deployed()

    console.log("Contract deployed to address:", vendingMachine.address)
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Hardhat node uses a default mnemonic phrase (docs) that can be derived into multiple pairs of private/public keys (20 by default). These accounts are unlocked at the local node.

Your snippet uses the ethers NPM package (imported by hardhat) that uses the first unlocked account to send transactions from (including deployment transactions), unless specified otherwise.

The project structure (e.g. contracts and test folders) is defined by the Hardhat framework - but you can change the default folder structure to a custom one (docs).

about 4 years ago · Juan Pablo Isaza Denunciar

0

Hardhat is a great tool that has some premade configuration to make the development easy, hardhat automatically injects the signers data to their version of ethers, in that way you automatically have the default signers or one made with the private keys or mnemonic that you can define in the hardhat config, if you don't select an specific signer when you create a contract instance hardhat is also smart enough to select the first item in the signer array.

About the getContractFactory, hardhat have some predifined routes to store the compiled contract data, but this can be overwrite in the hardhat config if you wish to, that way hardhat knows where to look for the data you are asking for

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda