I am trying to send ehter using this code
web3.eth.accounts.wallet.add(privateKey);
web3.eth.sendTransaction({
to:someAddress,
from:onwer,
value:amount*1,
gasPrice:result,
gas:21000,
nonce:nonce
}).
then(function (r) {
res.json({
response:r
})
}).catch(function(err){
res.json({error:err.message+"unknown tx"});
});
I keep getting
error: unknown account
But I add sender wallet explicitly in this part
web3.eth.accounts.wallet.add(privateKeyHere);
result is fetched from web3.eth.getGasPrice() Promise
nonce is fetched web3.eth.getTransactionCount(sender_address_here) Promise
What is wrong with the code ?
Can i send ether without sendSignedTransaction or other methods?
Which is the best (and most simple) method to send ether when you have private key using web3 ??
Thanks
EDIT 1 Account was create using
web3.eth.accounts.create();