[Ethereum] Broadcast another account’s signed transaction to the Ethereum Network

transactions

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?

Best Answer

[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.

Related Topic