Ethereum web3.eth.sendSignedTransaction不是一个函数

Ethereum web3.eth.sendSignedTransaction不是一个函数,ethereum,web3,Ethereum,Web3,我使用了web3.eth.sendSignedTransaction函数,但它不起作用 这是问题代码 var nonce = web3.eth.getTransactionCount("<from address>"); const txParams ={ nonce:web3.utils.toHex(nonce), to : "<to address>", value : web3.utils.numberToHex(web

我使用了
web3.eth.sendSignedTransaction
函数,但它不起作用

这是问题代码

  var nonce = web3.eth.getTransactionCount("<from address>");

  const txParams ={
      nonce:web3.utils.toHex(nonce),
      to : "<to address>",
      value : web3.utils.numberToHex(web3.utils.toWei('0.01','ether')),
      gasPrice :web3.utils.numberToHex(web3.utils.toWei('1','Gwei')),
      gasLimit:web3.utils.numberToHex('300000'),
      chainId :3          //Ropsten
  }
  const tx = new Tx(txParams);
  const privateKey = Buffer.from("<primary key>",'hex');
  tx.sign(privateKey);

  const serializedTx = '0x' + tx.serialize().toString('hex');
  console.log(serializedTx);
  web3.eth.sendSignedTransaction(serializedTx, function(err,txId){if(err){ console.log(' : ',txId)}});

但这是错误的

错误代码为“请将数字作为字符串或BigNumber对象传递,以避免精度错误。”

怎么了?我该怎么办

请帮帮我


谢谢。

我找到了一个方法,这个问题就消失了!我只是把web3的版本提高到1.0.0或更高版本。所以也许你可以试试。 就这样,

npm install -g web3@1.0.0-beta.52

我找到了一个方法,这个问题就消失了!我只是把web3的版本提高到1.0.0或更高版本。所以也许你可以试试。 就这样,

npm install -g web3@1.0.0-beta.52
npm install -g web3@1.0.0-beta.52