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?


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? – sapiensapiens Sep 6 '18 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 Sep 6 '18 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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