The first topic in the array is the sha3 hash of the hexadecimal representation of the canonical signature of the event. The remaining items in the topics array (there may be up to three) are the hexadecimal values of the indexed
parameters to the event. The event's remaining parameters (non-indexed) are stored in the 'data' field of the log.
For example, the ERC20 token Transfer
event, which is defined as
Transfer(address indexed _from, address indexed _to, uint256 _value)
has this canonical signature (A canonical signature is the name of event and the data types listed with no spaces):
Transfer(address,address,uint256)
which, when run through sha3, gives:
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
This is topic[0]. Topic[1] is the value of _from (padded with zeros to 32 bytes on the left), topic[2] is the value of _to (padded), and the non-indexed _value parameter is carried (in hex) in the log's data
field.
This transfer event:
Transfer(0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98,
0x9e0f70dec65e4a62b5c4df1317f47fd2ef707d6c,
10235417200000000)
generates this log:
{
"_from": "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
"_to": "0x9e0f70dec65e4a62b5c4df1317f47fd2ef707d6c",
"_value": 10235417200000000,
"address": "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
"data": "0x00000000000000000000000000000000000000000000000000245d0ec6557c00",
"logIndex": 0,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000fbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
"0x0000000000000000000000009e0f70dec65e4a62b5c4df1317f47fd2ef707d6c"
]
}
The address
field is the address of the smart contract that generated the event.