简体   繁体   中英

How Events in solidity are stored on ethereum blockchain?

I was reading Event's documentation. I encountered this paragraph. Can someone explains it in simple words?

You can add the attribute indexed to up to three parameters which adds them to a special data structure known as “topics” instead of the data part of the log. A topic can only hold a single word (32 bytes) so if you use a reference type for an indexed argument, the Keccak-256 hash of the value is stored as a topic instead.

  1. How transactions are stored on ethereum? ( w.r.t data structure )

  2. How Events are stored in transactions?

  3. How indexed arguments are stored?

  4. How reference type indexed arguments are stored?

I can only answer question 1,2

  1. Transactions are stored in a Patricia Merkle Tree, the so called Transaction Trie. The root of the Transaction Trie is stored in the block header, all transactions are appended in the block body. see: https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/

  2. Events are not stored in the transaction nor on the blockchain. They are stored within the transaction receipt. TX receipts are stored in the Receipts Trie by the node. Further the root of the receipts tree is stored onchain in the block header.

以太坊尝试

IMG Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM