0

Web3js has the following method :

web3.eth.signTransaction(transactionObject, address [, callback])

to sign a transaction using an unlocked account.

Can we sign a transaction in a similar way, without explicitly providing the private key, with ethereumjs-tx ?

8
  • 2
    I believe that the answer is no. Use web3.js if you have to rely on an unlocked account, but preferably - don't use an unlocked account. Sign the transaction before you send it to the node. Mar 31, 2020 at 7:36
  • @clement Why do you want to use ethereumjs-tx instead of signTransaction? Which functionality of ethereumjs-tx is missing?
    – Ismael
    Mar 31, 2020 at 18:15
  • @Ismael My objective is to sign a transaction on the client side, then send the raw transaction object to a backend server, and finally broadcast it from the back. As I set my web3 provider in my backend, I therefore don't want to use web3js in my frontend but a lower-level library instead.
    – clement
    Mar 31, 2020 at 20:31
  • @clement How will you manage the private key on the client side? Will you use MetaMask or you will handle it yourself?
    – Ismael
    Mar 31, 2020 at 21:15
  • @Ismael I will use Metamask.
    – clement
    Apr 1, 2020 at 6:55

0

Your Answer

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

Browse other questions tagged or ask your own question.