1

I checked there is difference between sendTransaction and sendSignedTransaction. (Can anybody Point out the Difference between Web3.eth.sendTransaction and web3.eth.signTransaction?)

but I found there are two sendTransaction methods on web3.js (v1.7.4).

First one is web3.eth.sendTransaction. (https://web3js.readthedocs.io/en/v1.7.4/web3-eth.html#sendtransaction)

The other one is web3.eth.personal.sendTransaction. (https://web3js.readthedocs.io/en/v1.7.4/web3-eth-personal.html#sendtransaction)

It seems the latter one has security issue though (use with web3.eth.personal.unlockAccount), What is use of first one?

I thought The general way of sending transaction on web3.js is below.

1.web3.eth.signTransaction 2.web3.eth.sendSignedTransaction

then, What is use of web3.eth.sendTransaction?

1 Answer 1

1

This is answer from @nikoulai on web3.js github repository issue. (https://github.com/ChainSafe/web3.js/issues/5191#issuecomment-1172155634)

here are two different questions.

First, regarding personal sendTransaction. Taken from the documentation:

The web3-eth-personal package allows you to interact with the Ethereum node’s accounts. So using this sendTransaction you are trying to execute the transaction using one of the accounts in the node.

Regarding the second part, web3.eth.signTransaction & web3.eth.sendSignedTransaction vs web3.eth.sendTransaction. Internally, sendTransaction signs the transaction and maybe is the most used. Signing and sending the transaction if different steps is more flexible. You can use an account to sign the transaction and another to send and pay for the fees etc.

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.