I am doing raw transaction to send token from one account to another. But I don't have private key of my account but i do have the password. How can I send raw transaction using my password only. Here is my code:
var Tx = require('ethereumjs-tx')
var Web3 = require('web3');
var web3 = new Web3(new
Web3.providers.HttpProvider('https://rinkeby.infura.io/infurakey'));
var Personal = require('web3-eth-personal')
var personal = new Personal(Personal.givenProvider)
var ABI =[{"constant":true,......","type":"event"}]
var contract =new web3.eth.Contract(ABI, '0x9...5bf3f4f')
const account1 = "0xd94acc...5071240364364c86f45";
const account2 = "0xf7689d04139...ad668CBF2Af2D29";
web3.eth.getTransactionCount(account1,(err, txCount)=>{
const txObject ={
from: account1,
nonce : web3.utils.toHex(txCount),
gasLimit: web3.utils.toHex(800000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
to: '0x9...a42255bf3f4f',
data: contract.methods.transfer(account2, 1000).encodeABI()
}
var password = new Buffer("mypassword", 'hex');
const tx = new Tx(txObject)
tx.sign(password);
const serializedTransaction = tx.serialize();
const raw = '0x' + serializedTransaction.toString('hex')
web3.eth.sendSignedTransaction(raw, (err, txHash)=> {
console.log('err:', err, 'txHash:', txHash)
})
})
I am getting error:
RangeError: private key length is invalid