[Ethereum] Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings

ethereumjs

Getting error while creating ethereum raw transaction

var rawTx = {
  nonce: '0x2a',
  gasPrice: '0x4a717c800',
  gasLimit: '0xc340',
  to: '0x73F7Ced8cc9D27DC426210c32fc6d0a40f941eE1',
  value: '0x2386f26fc10000',
  data: '',
  chainID: 4 
}      
var cTx = await new EthereumTx(rawTx, { 'chain': 'rinkeby' });
cTx.sign(privateKeyInBuffer);

Best Answer

try change data :'' to data:"0x"

Related Topic