I am using remix and ganache to test out my contract. The contract deploys successfully, however, I do not see the state variables initialized with the constructor parameters when I look at the deployed contract in remix... will appreciate any feedback on what is wrong with the following setup

    let rawTx = {
        from: runENV.acctAddr,
        nonce: runENV.web3.toHex(runENV.web3.eth.getTransactionCount(runENV.acctAddr)),
        //gasPrice: runENV.web3.toHex(20000000000),
        data: runENV.bin,
        arguments: ["param1", ["one", "two", "three"]],

    let transaction = new tx(rawTx);

    let serialzedTx = transaction.serialize().toString('hex');

    runENV.web3.eth.sendRawTransaction( '0x' + serialzedTx, (err, res) => {
            if(err) {
                console.log(`Error in deploying new record on bchain - ${err}`);
            } else {
                console.log(`record contract deployed successfully ${res}`);        

I have done similar work , what i found different was --> you have to pass data in you contract constructor as shown below :-

var data = require('../contractABI/data');
var contract_abi = abiData.abi;
var demo_Contract = web3.eth.contract(contract_abi);
//getting public keys 
var owner_add = <address of owner , you can use your address like sender/rec addr>;
var deployer_add = <address of deployer , you can use your address >;

let deploy = demo_Contract.new.getData(
        data: data.abiData,
let gas = web3.toHex(contract_data.gas_limit)
let gasPrice = web3.toHex(contract_data.gas_price)
let nonce = web3.toHex(web3.eth.getTransactionCount(deployer_add))
let transactionObject = {
    gas: gas,
    gasPrice: gasPrice,
    data: deploy,
    from: deployer_add,
    nonce: nonce
//getting private key of admin
var private_key = privateKeyService.getPrivateKey(contract_data.depemail).slice(2);
var txData = new Buffer(private_key, 'hex');
var transaction = new tx(transactionObject);
var serializedTx = transaction.serialize().toString('hex');

web3.eth.sendRawTransaction('0x' + serializedTx, function (err, txHash) {
    if (txHash) {
        txnStatus(txHash, (err, result) => {
            if (err) {
                next(err, null);
            } else {
                next(null, result);
    else if (err && err.message) {
        next(err.message, null);
    else {
        next('Unable to sendRawTransaction', null);

As i have created a deploy identifier and by using demo_contract(var demo_Contract = web3.eth.contract(contract_abi);) , you have to call getData method and pass arguments in you contract constructor.

In my case i have 5 arguments in my contract constructor which are :-






similarly you have to pass you arguments to constructor of your contract and then you have to pass this identifier in data of transaction object as shown in code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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