Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!