Skip to main content
added 29 characters in body
Source Link
biplavo
  • 934
  • 1
  • 7
  • 14

Using Web3.js 1.0.0

 var contractInstance = new web3.eth.Contract(contractABI);
var deployData = contractInstance.deploy({
    data : contractByteCode
}).encodeABI();

var tx = {
    data : deployData
};

web3.eth.accounts.signTransaction(tx, privateKey).then (signed => {
    web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log)
});

`signTransaction` is the function you need to sign your transaction with the private key. For that you need to construct a transaction with the required data for the contract deployment i.e. contract abi and its byte code. Now, you can sign the trasaction and send it. You will get contract address of the newly deployed contract and other information in transaction receipt.
var contractInstance = new web3.eth.Contract(contractABI);
var deployData = contractInstance.deploy({
    data : contractByteCode
}).encodeABI();

var tx = {
    data : deployData
};

web3.eth.accounts.signTransaction(tx, privateKey).then (signed => {
    web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log)
});

`signTransaction` is the function you need to sign your transaction with the private key. For that you need to construct a transaction with the required data for the contract deployment i.e. contract abi and its byte code. Now, you can sign the trasaction and send it. You will get contract address of the newly deployed contract and other information in transaction receipt.

Using Web3.js 1.0.0

 var contractInstance = new web3.eth.Contract(contractABI);
var deployData = contractInstance.deploy({
    data : contractByteCode
}).encodeABI();

var tx = {
    data : deployData
};

web3.eth.accounts.signTransaction(tx, privateKey).then (signed => {
    web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log)
});

`signTransaction` is the function you need to sign your transaction with the private key. For that you need to construct a transaction with the required data for the contract deployment i.e. contract abi and its byte code. Now, you can sign the trasaction and send it. You will get contract address of the newly deployed contract and other information in transaction receipt.
Source Link
biplavo
  • 934
  • 1
  • 7
  • 14

var contractInstance = new web3.eth.Contract(contractABI);
var deployData = contractInstance.deploy({
    data : contractByteCode
}).encodeABI();

var tx = {
    data : deployData
};

web3.eth.accounts.signTransaction(tx, privateKey).then (signed => {
    web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log)
});

`signTransaction` is the function you need to sign your transaction with the private key. For that you need to construct a transaction with the required data for the contract deployment i.e. contract abi and its byte code. Now, you can sign the trasaction and send it. You will get contract address of the newly deployed contract and other information in transaction receipt.