This content originally appeared on Level Up Coding - Medium and was authored by Henrique Centieiro
Ethereum Node Series V — How to get Ethereum transaction receipts, logs bloom and transaction details
In this article, I will assume that you read my other articles on the Geth Ethereum node and that you already have an Ubuntu machine running Ethereum Geth. If not, please go back to my other articles to find how to deploy and connect the Ethereum node:
- An Ethereum node running on Ubuntu. Check this article where I explain how to deploy an Ethereum node on Ubuntu AWS
- You already know a few commands to play around with the Etehreum network. Check this article where I talk about some commands to explore Ethereum blocks
- Also please get a pup ??
Let’s go over some additional functions on Geth, starting with the Transaction Receipt.
Assuming that you are in your Ubuntu machine with Geth installed, open the geth console by typing:
geth attach
Oh, and don’t forget, to do this you need to be running the node, i.e. your Ethereum node need to be at least synchronizing. If you need, check: how to deploy an Ethereum node on Ubuntu AWS for help.
Okay. Once you run geth attach, the function:
eth.getTransactionReceipt()
You can for example add a transaction hash:
eth.getTransactionReceipt(“0xc280ab030e20bc9ef72c87b420d58f598bda753ef80a53136a923848b0c89a5c”)
Will give us additional info on the transactions. To retrieve the transaction receipt from any transaction we need its hash.
In a transaction receipt, we can see a lot of useful information!
- blockNumber from which this transaction belongs (i.e. the height of the block where that transaction was included)
- blockHash which is the hash of the block (obviously!)
- contractAddress which is the contract associated to that transaction. In this case, it’s null because the transaction doesn’t involve a contract
- gasUsed is 21000, which is the fee paid to the miners to process the transaction. the gasUsed is measured in Gwei wich equals 0.000000001 Ether. Equally, 1 Ether equals 1 000 000 000 Gwei.
- root is the root hash of the rootState at the time of the transaction. This is like the hash of the entire blockchain until that moment
- and finally, we have also the transactionHash, which is obviously the hash of this transaction. duh!
Logs and Transaction details
Let’s now retrieve even more details from the Ethereum transactions! We can look at all the details such as BlockHash, BlockNumber, sender and receiver (from and to), gas, and much more of any given transaction by just using the transaction hash and the command
eth.getTransaction()
If we retrieve the transactionReceipt of the same transaction, we will get additional information: the logs and logsBloom.
Let’s use the following command to check the transactionReceipt (again):
eth.getTransactionReceipt()
Okay but…. what is logsBloom???
logsBloom is a 256 bytes string, and it’s not really a log in the classical sense. It’s the bloom filter for the logs of the block, and it allows to filter the hash of each element that is in the block. The objective is to minimize the number of queries that clients need to make by storing some events like historical transactions in the bloom. When there’s a query “Is data z in the set?” the response can be “maybe” or “no”. Thus is a probabilistic data structure.
Now we can see in the transaction receipt that there is a field called logs that is directly correlated with the logsBloom. The logsBloom is like a search field for the logs.
The address is the address that generated the transaction in the logs, and it can be either someone’s address or a smart contract. Then we have the blockHash, which is only the hash of the block from where this transaction belongs. We also have the blockNumber, again from the block where the transaction belongs to. Then we have the field data, topics it’s searchable in the logsBloom and shows some information such as what kind of event was this, and it is part of the ERC20 standard. The field data is thus, the canonical signatures of one of the following type of events that were introduced by Ethereum EIP20:
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function approve(address _spender, uint256 _value) public returns (bool success)
This 256 byte is a bloom filter which means that it is a probabilistic data structure, that tells you if a certain set of that does not exist or that maybe it exists. logsBloom allows simplifying search queries, reducing the amount of work that nodes need to do when a query or a search is performed. For example, if I’m searching for if that transaction belongs to the block 4344444, the logsBloom can already tell us if that transaction does not belong to this block or if it maybe belongs and then the logs field is checked. This method reduces the necessary amount of computing power to complete searches.
Ok, ok, I know that this is not the most interesting topic ever but someone has to write about it! ?
? Follow me, and please also check my ? blockchain courses:
? The First-Ever Dogecoin Course
?? Fintech, Cloud and Cybersecurity Course
?? Unblockchain Course — The Brain-Friendly Blockchain Course
Ethereum Transactions Receipts, Logs and Transaction details was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Henrique Centieiro
Henrique Centieiro | Sciencx (2021-07-19T01:26:22+00:00) Ethereum Transactions Receipts, Logs and Transaction details. Retrieved from https://www.scien.cx/2021/07/19/ethereum-transactions-receipts-logs-and-transaction-details/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.