I have this two kind of codes and I would like to know what is the difference between them:

First. .sign()

var tx = new Tx(rawtx);

Second .signTransaction()

web3.eth.accounts.signTransaction(tx, privateKey)

When should be used each of them?

1 Answer 1


I believe those are just two different libraries, so their methods have different names.

The first one looks like ethereumjs-tx, and the second one looks like web3.js 1.0 beta.

  • is there any difference between them when we use them? Commented Sep 6, 2018 at 17:29
  • 1
    They have different capabilities, but if you're just signing a transaction with a private key that you know, both methods will work.
    – user19510
    Commented Sep 6, 2018 at 18:05

Your Answer

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

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