Getting Invalid number of parameters for undefined when deploying smart contract

0 votes

I'm trying to deploy my first Voting contract on the testRPC and the below is my code.. I am not able to deploy it. 

The error seems to be from the arguments parameter. I tried passing an empty array and it said "Got 0 expected 1!". I tried passing just one name and it says "value.forEach" is not a function.

Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
sourceCode = fs.readFileSync('Voting.sol').toString()
solc = require('solc')
compiledCode = solc.compile(sourceCode)
abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
VotingContract = new web3.eth.Contract(abiDefinition)
byteCode = compiledCode.contracts[':Voting'].bytecode

    data: byteCode, 
    from: '0x00D1AE0A6fC13B9ecdefA118B94cF95ac16D4ab0', 
    gas: 4700000
.on('error', function(error) {
.then(function(newContractInstance) {
Oct 10, 2018 in Blockchain by digger
• 26,720 points

1 answer to this question.

0 votes

Try something like this for contracts that need constructor arguments

var bytecodeWithParam =
    { data: compiledByteCode });

It is this bytecodeWithParam that you paste into the "Byte Code" field. If you look at it in detail, you will see param1 and param2 32-byte packed at the end.

Another Example

var MyContract = web3.eth.contract(abiArray);

// instantiate by address
var contractInstance =;

// deploy new contract
var contractInstance =[constructorParam1] [, constructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});

// Get the data to deploy the contract manually
var contractData =[constructorParam1] [, constructorParam2], {data: '0x12345...'});
// contractData = '0x12345643213456000000000023434234'
answered Oct 10, 2018 by Omkar
• 69,170 points

Related Questions In Blockchain

0 votes
1 answer

Can a hacker change data of a smart sontract without call contract function?

A contract's content cannot be changed internally. ...READ MORE

answered Apr 7, 2018 in Blockchain by Shashank
• 10,400 points
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,100 points
0 votes
2 answers

How to get notified when an event triggers on ethereum smart contract?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2, 2020 in Blockchain by aqowcmbevs
0 votes
1 answer

Where are the transaction details of a smart contract is written in Ethereum?

First ques:where in the blockchain is a ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,400 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,830 points
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
+1 vote
4 answers

How to estimate the cost for deploying smart contract on mainnet?

Since you have already deployed the contract ...READ MORE

answered Apr 9, 2018 in Blockchain by Shashank
• 10,400 points
0 votes
1 answer