The Ethereum Classic (ETC) logging system records information about the ETC world computer. I will describe this logging system in detail.

Introduction

Users can submit requests to the ETC world computer. These requests may send funds as well as install or execute smart contracts. Accepted requests are recorded on the ETC blockchain as transactions. Logs pertaining to each transaction are also recorded on the blockchain.

Logs

For every transaction, the following information is logged:

final state root hash cumulative gas usage

For example, the final state root hash logged with regards to the third transaction of block 5,889,421 is:

0x915dd6ca7dca0c1d68c3cc84e0d8551394f353042af35bd6b5cf21084d643a27

That is the state root hash after the first three transactions have been applied. Since all transactions for that block require 21,000 gas, the cumulative gas usage logged with regards to the third transaction is 63,000 gas.

Logging Requests

Smart contracts can request the logging of additional information. Specifically, smart contracts can request the logging of named lists of values. For example, suppose a smart contract based game wanted to record the following information for a player:

account address health points gold coins

This information could be placed in a list named Player as in the following Solidity code declaration:

event Player(address user, uint256 health, uint256 gold);

Here is Solidity code to write specific player data to the blockchain:

emit Player(0xdf0b7310588741cad931de88bc6c4f687cdf0e16, 234, 198);

Note that variable values are stored but not variable names. Note also that user interfaces can access this logged information but that smart contracts cannot.

Logging requests are identified on the blockchain by hashes formed from their list names and list value types. For example, the aforementioned Player logging request is found on the blockchain by searching for the Keccak 256 hash of the string “Player(address,uint256,uint256)”.

Bloom Filters

Bloom filters are always included with all smart contract logging requests. Bloom filters are hashes created from data to speed up searches with regards to that data.

Indexed Values

Another way to speed up logging request searches is to store logging request values in a special way. Specifically, they can be stored as if they were additional logging request identifiers. This avoids having to extract them from the bytes encoding all the logging request values. Values stored in this manner are referred to as indexed values. For example, the Ethereum Token Standard specifies logging requests with indexed values as in this Solidity code:

event Transfer(address indexed sender, address indexed receiver, uint256 amount);

The log for transaction 0x104068d21afd428ce8eb5d9da155e11ba53414e40e088c884a678c6c203083d7 contains three logging request identifiers:

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 0x000000000000000000000000efb32e82cf9d65a828d6d99e12f0beab01a467a6 0x000000000000000000000000e71ac6142eaffc85ee3b9049facbcb13bc11402a

The first value is the Keccak 256 hash of the string “Transfer(address,address,unit256)”. The other values are the sending and receiving addresses with regards to the corresponding token transfer.

Peeve

Much source code and documentation refers to smart contract logging requests as “events”, transaction logs as “receipts”, and, logging request identifiers as “topics”. Perhaps the terms logging requests, transaction logs and logging request identifiers would have been more clear.

Conclusion

The blockchain always faithfully records all transaction logs. Smart contracts can log additional information which their user interfaces can search for and respond to. Now go create awesome smart contract applications with responsive user interfaces by leveraging the ETC logging system!

Feedback

Feel free to leave any comments or questions below. You can also contact me by clicking any of these icons:

Acknowledgements

I would like to thank IOHK (Input Output Hong Kong) for funding this effort.

License

This work is licensed under the Creative Commons Attribution ShareAlike 4.0

International License.