1

I'm writing some logic to identify the currency used in an ethereum transaction, and am wondering the following:

web3.eth.getTransaction returns a value field that indicates the value transferred in Wei.

However I'm using receipts, and web3.eth.getTransactionReceipt does not include the value transferred, which seems a little unintuitive. Why is this the case?

  • Often web3js tries to reflect the data as defined in the Yellow Paper, which doesn't include value in the receipt. It should be possible to write a method getTransactionAndReceipt, but it is kinda of subjective to include it in web3js or not. – Ismael Jan 2 at 19:12
1

Receipts are basically for proving logs and events, rather than details of a transaction.

In https://blog.ethereum.org/2015/11/15/merkling-in-ethereum Vitalik Buterin gave an example of using receipts, as well as other examples that can be answered with Merkle proofs:

  • Has this transaction been included in a particular block?
  • Tell me all instances of an event of type X (eg. a crowdfunding contract reaching its goal) emitted by this address in the past 30 days
  • What is the current balance of my account?
  • Does this account exist?
  • Pretend to run this transaction on this contract. What would the output be?

The first is handled by the transaction tree; the third and fourth are handled by the state tree, and the second by the receipt tree. The first four are fairly straightforward to compute; the server simply finds the object, fetches the Merkle branch (the list of hashes going up from the object to the tree root) and replies back to the light client with the branch.

Related:

| improve this answer | |

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.