I have the below js script to deploy my contract to the Ropsten test network. I am using @truffle/hdwallet-provider v2.0.8 and web3.js v1.7.3.

const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');
const dotenv = require('dotenv');

const compiledContract = require('./build/Campaign.json');

// Hex encoded bytecode is in evm.bytecode.object
const bytecode = compiledContract.evm.bytecode.object;
const interface = compiledContract.abi;

provider = new HDWalletProvider({
  mnemonic: {
    phrase: process.env.PRIVATE_KEY
  providerOrUrl: '<infura-node-url>'

const web3 = new Web3(provider);

const deploy = async () => {
  try {
    const accounts = await web3.eth.getAccounts();

    console.log('Attempting to deploy from account', accounts[0]);

    const result = await new web3.eth.Contract(interface)
      .deploy({ data: bytecode })
      .send({ gas: '1000000', from: accounts[0] });

    console.log('Contract deployed to', result.options.address);

    // To avoid deployment from hanging in the terminal
  } catch (error) {


However the same script works fine with web3.js v1.7.1 and @truffle/hdwallet-provider v2.0.4.

Stack trace:

Invalid number of parameters for "undefined". Got 0 expected 2!
(node:53572) UnhandledPromiseRejectionWarning: Error: Invalid number of parameters for "undefined". Got 0 expected 2!
    at Object.InvalidNumberOfParams (/home/millennial97/Projects/kickstart-dapp/node_modules/web3-eth/node_modules/web3-core-helpers/lib/errors.js:33:16)
    at Object._createTxObject (/home/millennial97/Projects/kickstart-dapp/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:694:22)
    at Contract.deploy (/home/millennial97/Projects/kickstart-dapp/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:525:33)
    at deploy (/home/millennial97/Projects/kickstart-dapp/ethereum/deploy.js:28:8

1 Answer 1


By the looks of the error, it seems that the contract you are deploying has some "constructor arguments". I cannot tell because you haven't shared the ABI or the contract code. Those arguments must be passed at deployment time

A would suggest you visiting this answer here https://ethereum.stackexchange.com/a/55597/45721

and change your structure to follow this set-up

    // You can omit the asciiToHex calls, as the contstructor takes strings. 
    // Web3 will do the conversion for you.
    arguments: ['Top 10 Students','Top10'] 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.