First Covalent API call
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that we are all set with the Covalent API key and an IDE to run code, let's start finding the answer for our question. So, how many Chi tokens were minted, burned and transferred on the 1st of May, 2021 on the Ethereum network?
Let's break it down in smaller steps so it's easier to follow..
As mentioned previously, a simple search on will retrieve the contract address for the Chi GasToken 0x0000000000004946c0e9F43F4Dee607b0eF1fA1c
Blockchain data is stored in blocks. This is a bit different from the traditional timestamp we are used to when querying data. The good news is that blocks have timestamps too and there is a Restful API that serves exactly this purpose, to provide a block based on the date you provide it: GET /v1/{chain_id}/block_v2/{start_date}/{end_date}/
If we look at the response we'll notice the following:
- the blocks are in ascending order so it's easy to spot the starting_block
that we need;
- it has pagination and contains a total_count
that allows us to compute the ending_block
without the need to make an additional call;
After running the code we get the block heights we need for the 1st of May, 2021, respectively starting_block = 12344945
and ending_block = 12351433
Now we are all set to have a closer look at the mints, burns and transfers for the Chi GasToken so make sure to follow this tutorial until the end.
We know that Chi is available on multiple networks so we need to get our hands on the Ethereum chain id. Looking at the in the Supported Networks section and there we see that the chain id for Ethereum is 1
.
We have all the necessary parameters to perform our first API call. I do suggest making this call in parallel from the browser on page so that it is easier to test and follow.