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

159
Vistas
Two methods of deploying contracts in Hardhat - how do they product the same result while being so different?

I have seen two methods of how Solidity smart contract get deployed on Hardhat. I would generalize them as follows:

METHOD 1

const hre = require("hardhat");
   
async function main() {

    const [deployer] = await ethers.getSigners();
      
    const contractFactory = await hre.ethers.getContractFactory("someContractName");
    const contractInstance = await contractFactory.deploy();

    await contractInstance.deployed();
    ...
    ...
}

main()
    .then(() => process.exit(0)) 
    .catch((error) => {
        console.error(error);
        process.exit(1);
    });

METHOD 2

    module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
        const { deploy, log } = deployments
        const { deployer } = await getNamedAccounts() 
        const chainId = await getChainId()
        const contractInstance = await deploy('myContract', {from: deployer,
            log: true,
        });
    ............
    ............
    
    }

While they both result in contract deployment, I am unable to understand how they both achieve the same results. how are these two deployment methods related, if at all? ( I would like to know what's going on under the hood )

about 4 years ago · Juan Pablo Isaza
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