Featured image: Neon handshake. Source Unsplash.

Welcome!

You will learn

What you must know already

What you need

Create an anyblock.tools query step-by-step

Retrieve all events indexed by anyblock.tools

curl -X POST \
https://api.anyblock.tools/ethereum/ethereum/mainnet/es/event/search/ \
-H' Authorization: Bearer $mytoken' \
-H' Content-Type: application/json'
"hits":{
"total":69502921,
"max_score":1,
"hits":[
...
]
}
{
"_index":"ethereum_2",
"_type":"event",
"_id":"0x92c1b864051b9e6758ab217bc70e0d8641d5f830e16b0a7d15ba78ef2356ba9c_e_52",
"_score":1,
"_routing":"0x251d33d4ab03fb675bb2d09304a4aca28b943373c0bd8dbc85402d9e23f4f061",
"_parent":"0x92c1b864051b9e6758ab217bc70e0d8641d5f830e16b0a7d15ba78ef2356ba9c",
"_source":{
"args":[
{
"name":"hash",
"value.hex":"b'eb8dd23ef00be18cb4a263b4271e2f9c28bb47a239f179001691f6e887a6ed47'",
"value.num":null,
"value.scaled":null,
"value.type":"bytes32",
"pos":0
},
{
"name":"registrationDate",
"value.hex":"0x59948642",
"value.num":1502905922,
"value.type":"uint256",
"pos":1,
"value.scaled":null
}
],
"event":"AuctionStarted",
"logIndex":{
"num":52,
"raw":"0x34"
},
"transactionIndex":{
"num":92,
"raw":"0x5c"
},
"transactionHash":"0x92c1b864051b9e6758ab217bc70e0d8641d5f830e16b0a7d15ba78ef2356ba9c",
"address":"0x6090a6e47849629b7245dfa1ca21d94cd15878ef",
"blockHash":"0x251d33d4ab03fb675bb2d09304a4aca28b943373c0bd8dbc85402d9e23f4f061",
"blockNumber":{
"num":4145267,
"raw":"0x3f4073"
},
"error":null,
"str":"AuctionStarted(b\"\\xeb\\x8d\\xd2>\\xf0\\x0b\\xe1\\x8c\\xb4\\xa2c\\xb4'\\x1e/\\x9c(\\xbbG\\xa29\\xf1y\\x00\\x16\\x91\\xf6\\xe8\\x87\\xa6\\xedG\", 1502905922)",
"timestamp":"2017-08-11T17:52:02"
}
}

Filter events from a specific contract

{
"query":{
"bool":{
"filter":{
"term":{
"address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
}
}
}
}
}
curl -X POST \
https://api.anyblock.tools/ethereum/ethereum/mainnet/es/event/search/ \
-H' Authorization: Bearer d2560f14-1935-44e7-ad3e-a1718dc03bd2' \
-H' Content-Type: application/json'
-d '{
"query":{
"bool":{
"filter":
{
"term":{
"address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
}
}
}
}
}'

Filter for a specific type of event

contractERC20Events{ eventApproval(addressindexedsrc,addressindexedguy,uintwad); eventTransfer(addressindexedsrc,addressindexeddst,uintwad); }
{ "query":{ "bool":{ "filter":[ { "term":{ "event.raw":"Transfer" } }, { "term":{ "address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" } } ] } } }
curl -X POST \
https://api.anyblock.tools/ethereum/ethereum/mainnet/es/event/search/ \
-H 'Authorization: Bearer d2560f14-1935-44e7-ad3e-a1718dc03bd2' \
-H 'Content-Type: application/json'
-d '{
"query":{
"bool":{
"filter":[
{
"term":{
"event.raw":"Transfer"
}
},
{
"term":{
"address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
}
}
]
}
}
}'

Retrieving sorted results

{ "query":{ "bool":{ "filter":[ { "term":{ "event.raw":"Transfer" } }, { "term":{ "address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" } } ] } }, "sort":{ "blockNumber.num":{ "order":"desc" } }, "size":5 }
curl -X POST \
https://api.anyblock.tools/ethereum/ethereum/mainnet/es/event/search/ \
-H 'Authorization: Bearer d2560f14-1935-44e7-ad3e-a1718dc03bd2' \
-H 'Content-Type: application/json'
-d '{
"query":{
"bool":{
"filter":[
{
"term":{
"event.raw":"Transfer"
}
},
{
"term":{
"address":"0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
}
}
]
}
},
"sort":{
"blockNumber.num":{
"order":"desc"
}
},
"size":5
}'

Restricting result size

Where to go from here

Sascha Göbel — Co-Founder of Anyblock

Interested or questions?

Anyblock Analytics is a German blockchain solution provider. We offer consulting, tools and data to integrate business processes with blockchain.