[Ethereum] how to sign transaction during contract deployment

web3js

I am looking at the web3js documentation to deploy a new contract, however, I see no mention of how to sign the transaction that will deploy the contract in the blockchain…document makes no mention of signing with private key…will appreciate any insight into this

here is the example code snippet from the docs (https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#eth-contract)

myContract.deploy({
data: '0x12345...',
arguments: [123, 'My String']
})
.send({
from: '0x1234567890123456789012345678901234567891',
gas: 1500000,
gasPrice: '30000000000000'
}, function(error, transactionHash){ ... })
.on('error', function(error){ ... })
.on('transactionHash', function(transactionHash){ ... })
.on('receipt', function(receipt){
console.log(receipt.contractAddress) // contains the new contract address
})
.on('confirmation', function(confirmationNumber, receipt){ ... })
.then(function(newContractInstance){
console.log(newContractInstance.options.address) // instance with the new contract address
});

Best Answer

enter image description here

This is the method which can be used to sign transactions.