Fetching Web3 Events Data

TUTORIAL

Naoufel

7/15/20232 min read

Tired to wait for Dune to index your contracts ? Let's see how we can skip the line with inverse.watch.

First of all there isn't any indexion happening here. We query directly the data from an EVM blockchain, so if it takes time it might have to do with your query returning to many lines. Get in touch with the AWG if you think it's an error.

So let's head to our favorite query editor and create a new Query. For this example we will select from the data source menu Ethereum Logs in order to catch events that happened on the mainnet.

The syntax to query for an event is specific to our platform, please respect it carefully. If you are like us and want to save time you can use the cool WEB3_EVENT snippet by typing its name and selecting it from the list. It will give you a template of the info you need to fill in. Once we have it, let's input the information to track INV transfers on mainnet.

Hereinafter is an example query that retrieves the transfers for INV token on the last 30 blocks :

contract_address: ["0x41D5D79431A913C4aE7d69a668ecdfE5fF9DFB68"]
event_name: "Transfer"
start_block: -30
end_block: 'latest'

You will notice that we have used relative parameters for the block arguments start_block and end_block. This provides a convenient way to screen only the latest transactions that happened on the network.
The use of a negative block for the start_block will instruct the query to calculate the start block relatively to the end block. Although there is no limit to this number, please avoid referencing a too ancient block if you are querying for frequent events for ressource and capacity reason.
Additionnaly the use of the 'latest' keyword in the end_block argument instruct the system to end the query at the most recent block at the time of initializing the query.  Note that you can also reference blocks by their number in the query.


So, let's get back to our query and hit 'Run Query' ... let's wait a few seconds et voila !

If you need to perform more advanced calculation to your data, like giving a date to the block time or give the amount a proper decimal, you might want to take a look at our doc : Querying Existing Query Results and use the result of the query we just designed as a datasource using our SQLite client.

Have fun on inverse.watch !