getTransaction 与 getTransactionReceipt

Anh*_* Lê 9 ethereum web3js

web3库中的web3.eth.getTransaction两种方法有什么区别?web3.eth.getTransactionReceipt我尝试阅读此文档https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#gettransactionreceipt但我不清楚其中的区别。

Pet*_*jda 17

收据仅适用于挖矿交易。但正因为如此,它还包含一些更多的属性:

  • status- 成功或恢复
  • gasUsed- 该交易单独使用的 Gas 量
  • cumulativeGasUsed- 该交易及其内部交易使用的 Gas 量
  • logs- 交易产生的事件日志列表

常规允许您获取尚未挖掘的交易的详细信息(getTransaction例如from,,和) 。可能的用例:您仅从外部来源获得,并且需要找出接收者,并且不知道交易是否已被挖掘。todatavaluetransactionHash

所以它们都可以在不同的情况下使用。