title: invalid type at Object.exports.toBuffer using web3
body: <p>I try to send a raw transaction to Ganache via Truffle.
  error message &quot;invalid type at Object.exports.toBuffer&quot;.</p>
  <p>Here is the code:</p>
  <pre><code>const Tx = require('ethereumjs-tx').Transaction;
  const privateKey = Buffer.from('5b58ae3fe5bf48d05f0a94c87a28fb480ec2bc200a4423ab42ea9557f3617743', 'hex');
  
  const payment_usercashTx = {
      nonce: myAsyncNonceFunction(),
      gasPrice: web3.utils.toHex(25000),
      gasLimit: web3.utils.toHex(10e9),
      to: '0x107180312267DB452930731EA475187BdD4948DB',
      from: web3.eth.defaultAccount,
      value: '0x00',
      data: encode_usercash
  }
  
  let usercashTx = new Tx(payment_usercashTx);
  usercashTx.sign(privateKey);
  
  let usercash_serializedTx = usercashTx.serialize();
  
  web3.eth.sendSignedTransaction('0x' + usercash_serializedTx.toString('hex'))
  .on('receipt', console.log);
  </code></pre>
  <p>New message:</p>
  <pre><code>Error: invalid type
      at Object.exports.toBuffer (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/bytes.js:97:19)
      at Transaction.setter [as nonce] (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:43:25)
      at /Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:96:38
      at Array.forEach (&lt;anonymous&gt;)
      at Object.exports.defineProperties (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:94:20)
      at new Transaction (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-tx/dist/transaction.js:127:27)
      at Object.&lt;anonymous&gt; (/Users/yuha/Desktop/blockchainProject/Kidari/routes/payment.js:72:18)
  </code></pre>