So I have two NodeJS applications, both implementing web3js. The first node is used for creating and signing transactions, then it sends raw signed transaction to the second node. Finally, the second node submit it to Ethereum network using the set provider.

However, I wonder can I use web3js on the first node "without" connecting it to any provider? We do not want the first node to connect to Internet at all (except connecting to second node) since it contains private keys of accounts.

  • How does the first node send the transactions to the second node? – cogitoergosum Sep 15 '18 at 5:52
  • I think you'll find it in your best interest to avoid keeping private information on your node. If I understand correctly, then you want this node to maintain an account which will be unlocked forever, instead of sending the private key to the node every time you need to unlock it. If that is the case, then please be advised that both options are potentially unsecured. The first one is unsecured if somebody gains access to your node. The second one is unsecured if somebody gains access to your connection. – goodvibration Sep 15 '18 at 7:22
  • AFAIK, the best way to deal with things here is to sign the transaction with your private key BEFORE you send it to the node. Then, the node has no knowledge of secret information - it doesn't store such information and it doesn't receive such information. – goodvibration Sep 15 '18 at 7:23
  • @cogitoergosum we use local networkto communicate between two nodes – richard Sep 15 '18 at 7:32
  • So anyone hacking the second node will eventually be able to hack the first node. – goodvibration Sep 15 '18 at 7:48

You do not need an instance of web3 to sign a transaction. For example you can use ethereumjs-tx to create the transaction and ethereumjs-wallet to manage your private key.

We have two servers: A connected to ethereum network where the transaction is created, ie filling correct nonce and updated gas price; and B that exposes an api to sign transactions.

  • Yes, it seems web3 instance requires a provider as its parameter. So we have to turn to ethereumjs-tx to sign the transaction. We have tried running the local ethereum network ganache-cli as its provider to make web3js works (so we do not have to change our current code). It works fine. – richard Sep 16 '18 at 6:15

Your Answer

