logs
This page describes the structure of the logs
index (Elasticsearch), and also depicts a few examples of how to query it.
_id
The _id
field for this index is composed of hex-encoded hash of the transaction of the smart contract result that generated the log.
Fields
Field | Description |
---|---|
address | The address field holds the address in a bech32 encoding. It can be the address of the smart contract that generated the log or the address of the receiver address of the transaction. |
events | The events field holds a list of events. |
originalTxHash | The originalTxHash field holds the hex-encoded hash of the initial transaction. When this field is not empty the log is generated by a smart contract result and this field represents the hash of the initial transaction. |
timestamp | The timestamp field represents the timestamp of the block in which the log was generated. |
Event structure
Field | Description |
---|---|
identifier | This field represents the identifier of the event. |
address | The address field holds the address in a bech32 encoding. It can be the address of the smart contract that generated the event or the address of the receiver address of the transaction. |
topics | The topics field holds a list with extra information. They don't have a specific order because the smart contract is free to log anything that could be helpful. |
data | The data field can contain information added by the smart contract that generated the event. |
order | The order field represents the index of the event indicating the execution order. |
Query examples
Fetch all the logs generated by a transaction
curl --request GET \
--url ${ES_URL}/logs/_search \
--header 'Content-Type: application/json' \
--data '{
"query": {
"match": {
"_id":"d6.."
}
}
}'
Fetch all the logs generated by a transaction and the smart contract results triggered by it
curl --request GET \
--url ${ES_URL}/logs/_search \
--header 'Content-Type: application/json' \
--data '{
"query": {
"bool": {
"should": [
{
"match": {
"_id":"d6.."
}
},
{
"match": {
"originalTxHash": "d6.."
}
}
]
}
},
}'