environment: Web3 0.20.7,Infura,node.js(backend) Deploy contract with Web3 0.20.7

pragma solidity ^0.5.1;

contract Bang{
    address holder;
    address proxy;
    constructor (address _holder, address _proxy) public {
    function getholder() public view returns(address){
        return holder;
var Tx = require('ethereumjs-tx');
var Web3 = require('web3');
const testnet = 'https://ropsten.infura.io/';
const web3 = new Web3(new Web3.providers.HttpProvider(testnet));
var wallet_address = "0x4b2194Fa5a.....";
var count = web3.eth.getTransactionCount(wallet_address);
var data = "0x608............"//from remix detail
var holder = "0xF2C44b7f10533....";
var proxy = "0xf21BF631C5382....";
var rawTransaction = {
  "from": wallet_address,
  "nonce": web3.toHex(count),
  "gasPrice": web3.toHex(5000000000),
  "gasLimit": web3.toHex(5000000),
  "data": data

var privateKey = new Buffer('CEA8070A7EC5........', 'hex');
var tx = new Tx(rawTransaction);

var serializedTx = tx.serialize();
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), 
  function(err, hash) {
    if (!err)

These codes would deploy that contract,but the constructor argument cannot be into the contract. How to insert the constructor argument in web3 0.20.7 with infura? enter image description here

1 Answer 1


Constructor argument shall be part of the data. A quick check to see if you have prepared the correct data is to check if the two addresses that you would pass to the constructor is part of var data = "0x608............"//from remix detail

If you don't like the hex data, you could use the web3.eth.Contract.deploy method to pass constructor parameters as an altenative solution. An example could be found in the documentation here.

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.