Is there a way to broadcast another account's transaction to the Ethereum network using Geth?

This question really won't make sense unless I describe my set-up.

1) Device A has a private key. It creates a transaction, signs it, and sends it to Device B

2) Device B is actually connected to the ethereum network, but doesn't know Device A's private key. It receives A's signed transaction and sends it to the network, no questions asked.

I'm running into a couple problems with this set-up. The first is the fact that Ethereum transactions require a nonce that must be strictly increasing with each of Device A's transactions. What happens if Device A crashes and loses its private key? How the heck would a person recover the value of their nonce in addition to their private key? Perhaps I am misinterpreting the nonce itself -- Does the nonce limit the private key's transactions, or is it increased when a node sends a transaction? In the latter case, I imagine I would need to poll Device B to obtain a nonce before signing the transaction. Is there any other data I would want to get, like the gas price?

I haven't gotten to step 2 yet, but I'm expecting this to be the real difficulty. Does geth even allow you to send another account's signed transaction? Surely there must be some core protocol beneath geth that I can access to do this for me?

Is it really impossible for something like this to be done using Ethereum's account system?

[this is probably not the most elegant solution]:

  • you setup geth on device A and device B
  • device B is running the vanilla geth with default startup nodes that it connects to
  • device A is having only one startup node (device B) and does not allow any other connections
  • device B formats and signs a tx and broadcasts it in the default way. since it is only connected to device B, it will effectively only send the signed tx to device A which is then doing the broadcasting to the whole network.

What happens if Device A crashes and loses its private key

You better have an encrypted backup of the private key stored in multiple secure locations

How the heck would a person recover the value of their nonce in addition to their private key?

The nonce is stored in the global account list on every node, no need to back it up. You can obtain it via web3.eth.getTransactionCount(accountAddress).

Does the nonce limit the private key's transactions, or is it increased when a node sends a transaction?

The latter, it increases on every valid tx that was signed by the corresponding private key and broadcasted.

up vote 0 down vote accepted

ethereumjs-tx is a library with this example:

npm install ethereumjs-tx

var Tx = require('ethereumjs-tx')
var privateKey = new Buffer('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex')

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000', 
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000', 
  value: '0x00', 
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

var tx = new Tx(rawTx)
tx.sign(privateKey)

var serializedTx = tx.serialize()
console.log(serializedTx.toString('hex'))

Then, send the signed JSON string to device B, and have them broadcast it to the network. Don't worry about the nonce.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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