sendSignedTransaction() - invalid sender error

Please help me !!!

var Tx = require(‘ethereumjs-tx’).Transaction
const Web3 = require(‘web3’)
const web3 = new Web3(‘https://rinkeby.infura.io/v3/c31f5371421b4966b54c…2214a0f2’)

const account1 = ‘0x197bE68cDbf27A7Bebd81b4784A3DC00d4f6DD78’ // Your account addres
const account2 = ‘0x852132E98cEdBBA5BaA44011baEB2baeBcC56eAB’ // Your account address 2

const privateKey1 = Buffer.from(‘FC00F39513CF4995C3E0BD59…A658E1870A46DA6817A128D155C59907B’, ‘hex’)
//const privateKey2 = Buffer.from(‘YOUR_PRIVATE_KEY_2’, ‘hex’)

web3.eth.getTransactionCount(account1, (err, txCount) => {
// Build the transaction
const txObject = {
nonce: web3.utils.toHex(txCount),
to: account2,
value: web3.utils.toHex(web3.utils.toWei(‘0.1’, ‘ether’)),
gasLimit: web3.utils.toHex(21000),
gasPrice: web3.utils.toHex(web3.utils.toWei(‘10’, ‘gwei’)),
chainId: 4
}

// Sign the transaction
const tx = new Tx(txObject)
tx.sign(privateKey1)

const serializedTx = tx.serialize()
const raw = ‘0x’ + serializedTx.toString(‘hex’)

// Broadcast the transaction
web3.eth.sendSignedTransaction(raw, (err, txHash) => {
if (err) {
console.error(err)
return
}
console.log(‘txHash:’, txHash)
// Now go check etherscan to see the transaction!
})
})

/////////////////////////////////////////////////////////////////////////////////////////

Error: Returned error: invalid sender
at Object.ErrorResponse (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/web3-core-helpers/src/errors.js:29:16)
at /home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/web3-core-requestmanager/src/index.js:140:36
at XMLHttpRequest.request.onreadystatechange (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/web3-providers-http/src/index.js:96:13)
at XMLHttpRequestEventTarget.dispatchEvent (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
at IncomingMessage. (/home/shan/Dropbox/AWAX/Ethereum-Client/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1161:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11)

This looks like an issue with version 2.0.0 of ethereumjs-tx: https://github.com/ethereumjs/ethereumjs-tx/issues/165

You will need to construct your transaction like below:

const tx = new Tx(txObject, {chain:'ropsten', hardfork: 'petersburg'})