Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ethereum Web3:传输出错_Ethereum_Web3_Web3js_Ether - Fatal编程技术网

Ethereum Web3:传输出错

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

我尝试使用ROPSTEN网络传输ETH,首先我在MetaMask中进行了测试,两个地址都能够在没有任何问题的情况下进行事务处理。因此,我开始在我的应用程序中使用
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