I trying to transfer ETH using ROPSTEN network, at first I had tested in MetaMask and both address are able to do the transaction without any problem. So, I start to try out in my application using web3@1.0.0-beta.34
, however the response are giving me Error: Returned error: insufficient funds for gas * price + value
What I guess is the error nothing do with the balance or gas, just not sure which part I doing not right.
const web3 = new Web3('https://ropsten.infura.io:443');
var count = await web3.eth.getTransactionCount(publicaddress);
var gasPrices = await this.getCurrentGasPrices();
var rawTransaction = {
"from": selectedWallet.publicaddress,
"nonce": count,
"gasPrice": gasPrices.low * 100000000,
"gas": web3.utils.toHex("519990"),
"to": recipientaddress,
"value": web3.utils.toWei(new Web3.utils.BN(setamount), 'ether'),
};
var privKey = new Buffer(privatekey,'hex');
var tx = new Tx(rawTransaction,{'chain': 'ropsten'});
tx.sign(privKey);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), (err, hash) =>{
if (!err){ //SUCCESS
console.log("success", hash);
}else{
console.log(err);
}
});