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

342
Views
How do I run Hardhat with the --constructor-args parameter?

I'm trying to run a script with Hardhat to deploy a contract which has constructor arguments. When I run npx hardhat run scripts\deploy.js --network rinkeby I get the error:

Error: missing argument: in Contract constructor (count=0, expectedCount=7, code=MISSING_ARGUMENT, version=contracts/5.5.0)

I've tried to use the --constructor-args parameter but get another error:

Error HH305: Unrecognized param --constructor-args

All the references I've found to constructor-args suggests that it's only available as part of hardhat verify, not hardhat run but if that's the case how can I pass arguments when deploying?

Updated to include deploy script

// deploy.js

async function main() {
    const [deployer] = await ethers.getSigners();

    console.log('%c \n Deploying contracts with the account:', 'color:', deployer.address );

    console.log('%c \n Account balance:', 'color:', (await deployer.getBalance()).toString() );

    const Token = await ethers.getContractFactory("Test01");
    const token = await Token.deploy();

    console.log('%c \n Token address:', 'color:', token.address );
    
    
}

main()
    .then( () => process.exit(0) )
    .catch( (error) => {
        console.error(error);
        process.exit(1);
    });
    ```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const Token = await ethers.getContractFactory("Test01");
const token = await Token.deploy();

Token (capital T) is an instance of the ContractFactory. As per the docs, you can pass the constructor arguments to the deploy() method.

For example, if your Solidity constructor takes a bool and a string

constructor(bool _foo, string memory _hello) {
}

this would be the JS snippet:

const token = await Token.deploy(true, "hello");
about 4 years ago · Juan Pablo Isaza Report
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!