I'm trying to send ether from one address to another. I have a valid generated address and a private key for that. I have a node is working on Linux in fullmode and RPC server listening on the default port. According to JSON RPC Wiki I'm trying to create the following transaction:

String transaction = "
  "from": "my address",
  "to": "an address of a recipient",
  "value": "a value in Wei converted to Hex String",
  "chainId": 1,
  "nonce": 0

And then I'm creating a signature like

String txData = makeKeccak256(privateKey + transaction.toHex());

And sending this string as Hex to RPC server. But I'm getting the following error:

rlp: expected input list for types.txdata

I've read that the gasPrice and gas are calculating automatically and are optional. So please help me to find out how to send the transaction correctly. Thank you

1 Answer 1


You can also sign a transaction using ethereumjs-tx. Give this try,

const Tx = require('ethereumjs-tx');

const rawTx = {
  from: 'Your account address,
  to: 'Recipient account address',
  value: 'Values in wei

var tx = new Tx(rawTx);

tx.sign('Your private key in buffer');

var stx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + stx.toString('hex'), (err, hash) => {
  if (err) { 

To send exact values of nonce and gasPrice use web3.eth.estimateGas and web3.eth.getTransactionCount methods.

  • Thank you for your reply. What does exactly do that method "sign". Is it a hash calculation with Keccak algo? And same for "serialize", what is it. I just have to use RPC server of Geth and work via TCP socket so I'm filling out headers, json body etc., therefore I need to know internal details :D
    – G-Virus
    Jun 3, 2019 at 11:06
  • "sign" - it will sign a transaction object using a private key and generate a signature on it. "serialize" - There are two ways to send transaction: sendTransaction and sendSignedTransaction. When private key is not handled by any third party like Metamask, we need to perform serialization before sending. Jun 3, 2019 at 12:53
  • Then I do it correctly, I guess? I'm converting Json object with transaction data to hex string, concatenating it with private key data converted to hex string and then calculating keccak256 hash. And then I push this data to sendRawTransaction. But something is wrong...
    – G-Virus
    Jun 3, 2019 at 14:10
  • 1
    Well, I found a reason why it doesn't work - a raw transaction must be encoded to RLP format. It requires nonce, gasPrice, gasLimit, recipientAddress, amount, comment, r, s, v fields in that order. I've read RLP documentation and follow it during transaction creation, but now I'm getting an error "rlp: input string too long for common.Address, decoding into (types.Transaction)(types.txdata).Recipient". The address is valid and encoded properly according to RLP. Any ideas what is going wrong?
    – G-Virus
    Jun 5, 2019 at 16:52
  • I have no idea about that. You should ask another question related to RLP issue. It will reach to more people. Jun 5, 2019 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.