Ethereum Web3:传输出错
我尝试使用ROPSTEN网络传输ETH,首先我在MetaMask中进行了测试,两个地址都能够在没有任何问题的情况下进行事务处理。因此,我开始在我的应用程序中使用Ethereum Web3:传输出错,ethereum,web3,web3js,ether,Ethereum,Web3,Web3js,Ether,我尝试使用ROPSTEN网络传输ETH,首先我在MetaMask中进行了测试,两个地址都能够在没有任何问题的情况下进行事务处理。因此,我开始在我的应用程序中使用web3@1.0.0-beta.34,但是响应给了我错误:返回的错误:用于天然气的资金不足*价格+价值 我猜错误与天平或气体无关,只是不确定哪一部分不对 const web3 = new Web3('https://ropsten.infura.io:443'); var count = await web3.eth.getTransa
web3@1.0.0-beta.34
,但是响应给了我错误:返回的错误:用于天然气的资金不足*价格+价值
我猜错误与天平或气体无关,只是不确定哪一部分不对
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);
}
});
它对我来说毫无错误 因此,可能的原因:
0x
设置了privatekey