var EthereumTransaction = require("ethereumjs-tx")
var Web3 = require('web3')
var web3 = new Web3('http://127.0.0.1:7545')
//Setting Receiving and Sending Address
var sendingAddress = acc1
var receivingAddress = acc2
//Checking the balance of each account in ether
web3.eth.getBalance(sendingAddress).then(console.log(web3.utils.fromWei('1', 'ether')))
web3.eth.getBalance(receivingAddress).then(console.log(web3.utils.fromWei('1', 'ether')))
//Creating a transaction
var rawTransaction ={
nounce:0,
to:receivingAddress,
gasPrice:20000000,
gasLimit:30000,
value:100,
data:""
}
//Sign the Transaction
var privateKey = 'private key goes here'
var senderPrivateKeyHex = new Buffer(privateKey,'hex')
var transaction = new EthereumTransaction(rawTransaction)
transaction.sign(senderPrivateKeyHex)
//Send transaction to the network
var serializedTransaction = transaction.serialize()
web3.eth.sendSignedTransaction(serializedTransaction)
Error Occurred is.
TypeError: EthereumTransaction is not a constructor
npm ls ethereumjs-tx
in a console and tell us what you're getting.