This article environment:
Blockchain version: Ethereum POA alliance chain
Node version: geth 1.9.19
nodejs version: v10.14.0
Operating system: windows 64
This article tests the code (web3.js) for deploying smart contracts with private keys.
1. The deployment contract code given in the official document
In the official document ( https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html ), the code for deploying the smart contract is given:
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',