Hi @gaio,
No … it’s not the transaction ID … that appears separately at the top of the whole transaction receipt as the transaction hash
(below status
).
"topic"
is the hash of the event name and its parameter types. This is known as the event signature e.g.
// For the event ....
event Transfer(address indexed from, address indexed to, uint256 amount);
// "topic" is the Keccak-256 hash of ...
Transfer(address, address, uint256)
Yes …
When a transaction emits an event, there can actually be from 1 to 4 topics stored in an Ethereum log record on the blockchain:
-
The first topic is the hash of the event name and its parameter types (as descibed above)
-
The other 3 topics will only be generated for any of the emitted event’s parameters which are indexed
— one topic for each indexed
parameter — which is why the maximum number of parameters that can be indexed
in a single event is 3
It is the topics which enable event data (stored in log records on the blockchain) to be searched, or listened for, according to specified parameters. For example, if none of the parameters are indexed, I think you can only search or listen by event name (e.g. all Transfer events). However, with my Transfer event example with 2 indexed address parameters …
event Transfer(address indexed from, address indexed to, uint256 amount);
… you could also search and listen for only those transfers (i) from a specific sender’s address (ii) to a specific recipient’s address, or even (iii) only those with both a specific sender’s address and a specific recipient’s address; but as the amount parameter isn’t indexed, you couldn’t search or listen for transfers of a specific amount.
I’ve tested calling a function which emits an event with indexed parameters, in Remix, but still only one topic appears in the transaction receipt logs. This is probably because the transaction receipt generated in Remix is what has been selected from the encoded data for presentation in the frontend in a simplified, human-readable format. In the following article (which includes some nice diagrams) you can read more detail about “topics” and how the other non-indexed event data is stored on the Ethereum blockchain in log records, how the EVM generates these for emitted events, and also about the other cost and data-type/structure factors that need to be considered (as well as searchability) when deciding which parameters to declare as indexed
.
https://medium.com/mycrypto/understanding-event-logs-on-the-ethereum-blockchain-f4ae7ba50378
The following article is also quite a nice introduction and overview of the contents of transaction receipts in Remix, and how they are generated:
https://medium.com/remix-ide/the-anatomy-of-a-transaction-receipt-d935aacc9fcd
And finally — despite having been written 5 years ago — the following article provides some good background information about events and logs in general:
https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e#.7w96id6rs
Happy reading 