# Mints, burns and transfers

### Step 5: Get data for mints, burns and transfers

The way to approach this is by using another Covalent endpoint, respectively `GET /v1/{chain_id}/events/address/{address}/` .

As I mentioned before, it is better to first try it out directly in the browser on [Covalent's page](https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/events/address/{address}/) to see the response first and also have an overview of the parameters you can play with.

So let's do just that in order to analyze the first transaction so you can adjust the parameters accordingly and see how the final curl will look like. You'll be able to check the details for `RESPONSE`, `RESPONSE HEADERS` and `CURL`at the bottom:

![](/files/-MatWmzA2zsw_Oqr0A-l)

A good start would be `curl -X GET "`[`https://api.covalenthq.com/v1/1/events/address/0x0000000000004946c0e9F43F4Dee607b0eF1fA1c/?starting-block=12344945&ending-block=12351433&key=ckey_a0b7bb48fadf475c8f1258a5c35`](https://api.covalenthq.com/v1/1/events/address/0x0000000000004946c0e9F43F4Dee607b0eF1fA1c/?starting-block=12344945\&ending-block=12351433\&key=ckey_a0b7bb48fadf475c8f1258a5c35)`"  -H "Accept: application/json" \` and then analyze the first transaction in the items array:&#x20;

```
5       {
6         "block_signed_at": "2021-05-01T00:01:31Z",
7         "block_height": 12344946,
8         "tx_offset": 1,
9         "log_offset": 18,
10         "tx_hash": "0xe417bff17f92fea22b873e1d7235934660486edbbfd4d977fa69a0de71f69925",
11         "_raw_log_topics_bytes": null,
12         "raw_log_topics": [
13           "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
14           "0x00000000000000000000000073fe72f0646795fed399754c6967fbfc510cf804",
15           "0x0000000000000000000000000000000000000000000000000000000000000000"
16         ],
17         "sender_contract_decimals": null,
18         "sender_name": null,
19         "sender_contract_ticker_symbol": null,
20         "sender_address": "0x0000000000004946c0e9f43f4dee607b0ef1fa1c",
21         "sender_address_label": "1inch Network: CHI Token",
22         "sender_logo_url": null,
23         "raw_log_data": "0x0000000000000000000000000000000000000000000000000000000000000005",
24         "decoded": {
25           "name": "Transfer",
26           "signature": "Transfer(indexed address from, indexed address to, uint256 value)",
27           "params": [
28             {
29               "name": "from",
30               "type": "address",
31               "indexed": true,
32               "decoded": true,
33               "value": "0x73fe72f0646795fed399754c6967fbfc510cf804"
34             },
35             {
36               "name": "to",
37               "type": "address",
38               "indexed": true,
39               "decoded": true,
40               "value": "0x0000000000000000000000000000000000000000"
41             },
42             {
43               "name": "value",
44               "type": "uint256",
45               "indexed": false,
46               "decoded": true,
47               "value": "5"
48             }
49           ]
50         }
51       },
```

What you'll notice is that `decoded.params`contains data that allows us to filter all the mints and burns and also it give use the `value`for the transaction. So let's start filtering our transactions!

### Step 6: Filter transactions with `Primer`

`Primer`is a query language offered by Covalent that allows us to process and transform records retrieved with the Covalent API.  You can read more about it [here](https://www.covalenthq.com/docs/learn/tutorials/query-with-primer-beg).

You will make use of `Primer` by using one of it's basic functionality by performing a simple `match` in order to filter our transactions:

![](/files/-MatVwRBGL6PMyAuvRwQ)

So how do should this parameter be written, especially for deeply nested documents? The answer is simple, by inputting a  `<field>:<value>` expression combined with the dot notation.

Let's try it out for filtering mints!&#x20;

Since you need to access `from` apply an equality condition to retrieve all the transactions `<from>:<0x0000000000000000000000000000000000000000>`and access the `decoded.params.0`, our parameter for `match` will look like this: `{"decoded.params.0.value":"0x0000000000000000000000000000000000000000"}`

{% hint style="info" %}
**Tip!** Increase the `page-size` when using `Primer` to make sure you are including a higher number of transactions (default is 100).
{% endhint %}

You'll make the API call and once you've received the response, iterate over the array with the `map`function to extract only the values and then use the `reduce`function to sum everything up:&#x20;

{% embed url="<https://replit.com/@snowdot/getChiMints>" %}

Awesome! You now have to total value of Chi GasTokens that have been minted on the 1st of May, 2021: `totalChiMintedValue = 67263`

Now let's rinse and repeat the process for burns!&#x20;

This means that the `match` parameter must be updated and filter by the transactions `<to>:<0x0000000000000000000000000000000000000000>`: `{"decoded.params.1.value":"0x0000000000000000000000000000000000000000"}` :

{% embed url="<https://replit.com/@snowdot/getChiBurns>" %}

You did it again! The total value of Chi GasTokens that have been burned on the 1st of May, 2021 is `totalChiBurnedValue = 10092`

Saving the best for last, the Chi transfers!\
Since you've gained some experience working with `Primer` let's take your skills to the next level in order to extract the Chi transfers!&#x20;

In order to define our `primer`query string parameter, you'll have to take a look again at the [Covalent docs](https://www.covalenthq.com/docs/learn/tutorials/query-with-primer-int) about `Primer` and combine the `$not` (!== not equal to) comparison operator with the `$and` logical operator. This will retrieve all the transactions that aren't `from`or `to`the contract address `0x0000000000000000000000000000000000000000`and this is how our query string looks like:

`[{$match:{$and:[{$not:{decoded.params.0.value:0x0000000000000000000000000000000000000000}},{$not:{decoded.params.1.value:0x0000000000000000000000000000000000000000}}]}}]`

Run the code with it once you've received the response, take the following steps:\
\- `filter`transactions that have the name "Transfer";\
\- iterate over the array with the `map`function to extract the values;\
\- use the `reduce`function to sum everything up:&#x20;

{% embed url="<https://replit.com/@snowdot/getChiTransfers>" %}

Congrats! You also have now the total value of Chi GasTokens that have been burned on the 1st of May, 2021:`totalChiTransferredValue = 120182`

{% hint style="info" %}
If you are curious about finding out the answer to the same question but for a different network (e.g. Binance Smart Chain) all you need to do is change the `chain_id`parameter.
{% endhint %}

Amazing work! You've officially found the answer for our original question *How many Chi tokens have been minted, burned and transferred on 1st of May, 2021 on the Ethereum network?*, and that is:\
\- total Chi minted: **67,263**\
\- total Chi burned: **10,092**\
\- total Chi transferred: **120,182**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://snowdot.gitbook.io/a-closer-look-at-chi-gastoken/mints-burns-and-transfers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
