16

Reading the documentation of web3.js I have come across sending transactions and raw transactions.In the documentation it's specified that send raw transaction sends an already signed transaction.

Does this imply that web3.js does not sign transactions when sendTransaction() is called?

Sebi
  • 5,294
  • 6
  • 27
  • 52

1 Answers1

16

All transactions need to be signed. Otherwise they are considered invalid transactions and will not be included in the blockchain.

A raw transaction is a transaction in raw bytes. If one has the raw bytes of a valid transaction, they can use sendRawTransaction. Otherwise, web3.js creates the signed transaction's bytes for you automatically as part of sendTransaction(). web3.js converts the JSON transaction {from:..., to:..., value:...} to the raw bytes and signs it for you automatically.

Raw bytes are required if you are using a platform like infura.io which does not handle private keys but deal only with signed transactions.

Chim
  • 471
  • 3
  • 11
eth
  • 85,679
  • 53
  • 285
  • 406
  • I asked a related / follow up question here: https://ethereum.stackexchange.com/questions/18928/what-is-a-raw-transaction-and-what-is-it-used-for – Tesa Jun 27 '17 at 17:35
  • @Tesa Thanks. I will try to write a good answer for it (someone fast has already written one), might take few days. – eth Jun 28 '17 at 00:28