Overview of Covalent API features: Solving the #OneMillionWallets Avalanche Wallet Puzzle Challenge as a case study — Part 2.

Jason Win
9 min readApr 24, 2021

Hello everybody!

Kindly read Part 1 here.

Before I continue my story about the second round of the coolest quest — Wallet Puzzle Challenge, I would like to share some thoughts that I had after passing the first stage.

Data Analytics — The Next Breakout Area of the Crypto Space

Last year, the cryptocurrency market brought a large number of participants a good profit. Almost all of my friends who survived the 2018–2019 year now have excellent capital relative to the average income of a person. However, it is still quite different for everyone. Of course, we are talking about tens or even hundreds of thousands of dollars, but why is this happening?

It’s all about skills, knowledge, and information.

There is a category of market participants who earn a lot of money in testnet. They have unique knowledge and skills that allow them to launch nodes and participate in the early stages, receiving decent dividends for these in the future.

There are people who specialize in multi-accounts and have huge farms. Personal opinion: I do not approve of this, but it is a fact.

I also know people who successfully earn a lot of money by analyzing smart contracts, transactions, swaps, and other information.

I want to go into more detail here in this article. With the development of Decentralized Exchanges (DEX), any market participant has the opportunity to track absolutely every detail and have accurate information on trading volumes, liquidity, etc. There is a whole layer of analytical data, which, when properly processed, can show an absolutely amazing result and, one might say, exclusive information. In fact, collecting and processing such information is a huge work, not possible for everyone. Thus, we then return to the talk about skills.

However, with the advent of a tool such as the Covalent API, everything becomes 10x easier. After all, using a simple and intuitive UI makes the task much easier. Therefore, I am sure that several analytical companies will use the Covalent API to offer their users processed analytical information in the future.

Generally speaking, all successful market participants are united by the availability of useful skills and timely information.

What we are going to do in the Wallet Puzzle 2 quest is: Demonstrating the skill to work with the Covalent API by sourcing unique information!

Wallet Puzzle Challenge Round 2

In this round, I again encountered problems that arose due to inattentive reading of the task. I can only justify myself by saying that I did all this late at night, after work, and wanted to sleep :)

But let’s take it in order.

Unlike the first round, the Wallet Puzzle round 2 task was described in great detail, and each step was explained as much as possible in the instructions.

Main task.1. Find the total number of SWAPS on Pangolin for the top 2 swap pairs (by overall count) in the first week of April 2021 from April 1, 00:00:00 UTC until April 7, 23:59:59 UTC.2. Convert this total into hexadecimal and you will unlock the secret room for the next task at the URL:www.onemillionwallets.com/{hexadecimal_number}

The main task is divided into steps, which the creator of the quest described in great detail.

Step 1.Go to Covalent’s AlphaAlarm Twitter: https://twitter.com/AlphaAlarm_HQ. Find the Tweet which explored the most popular swaps on @pangolindex. Identify the the top 2 swap pairs (by overall count) which all include Wrapped AVAX (WAVAX). WAVAX is the ERC-20 compatible version of Avalanche’s native token AVAX.

Here everything is straightforward, we open the necessary account on Twitter and look for the necessary tweet with the description of the most popular trading pairs on Pangolin DEX.

I found the tweet. It wasn’t difficult.

As you can see, the two most popular pairs are

PNG/ WAVAX

USDT/ WAVAX.

Let’s remember this.

Step 2. With the information from step 1, go to https://info.pangolin.exchange Find the token pair contract address for each of the top 2 tokens from step 1. For example, if one of the top token pairs shown is SUSHI/WAVAX, search for SUSHI-WAVAX at https://info.pangolin.exchange to get the contract address 0xd8B262C0676E13100B33590F10564b46eeF652AD which is shown truncated at the top Pairs → SUSHI-WAVAX (0xd8b262…f652ad) in the following image:

In the second step, we need to find the Smart Contract addresses for the selected pairs from step 1. In the description of the step, even the place where to search is indicated. This is also a straightforward step. First, go to this address https://info.pangolin.exchange/, then in the right-side navigation menu, click on the “Pairs” tab.

And we find the necessary pairs in the list. Then, open each of them, and we find the address of the contract, as shown in the guide to step 2.

Two necessary addresses:

PNG/ WAVAX : 0xd7538cabbf8605bde1f4901b47b8d42c61de0367

USDT/ WAVAX : 0x9ee0a4e21bd333a6bb2ab298194320b8daa26516

Step 3. Every time a SWAP takes place in a contract, an event called Swap is emitted by the contract and categorized under a topic hash. This is how users can find all the Swap events associated with any particular contract.Take a look at the log events for our example SUSHI-WAVAX contract: https://cchain.explorer.avax.network/address/0xd8B262C0676E13100B33590F10564b46eeF652AD/logs
You will find the topic hash as the first hash value listed under Topics. Note — this topic hash value will be the SAME for all Swap events emitted by ALL Pangolin token pair contracts!Double check that the SWAP topic hash for each of the 5 token pairs is indeed the same.

At this step, the author of the quest tells us that: in the network, all operations are classified and marked with a specific hash. I hope you have not forgotten that we needed to find “SWAPS” in the task to look for the topic hash for swaps.

Following the link from step 3, you can see that the topic hash for swaps is identified as 0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822

However, this is the first time I’ve used all this data. So we had to make sure that it was the correct hash. Next, I opened the contracts of other pairs; this is PNG/ WAVAX.

And this is USDT/ WAVAX:

As you can see, the hash is the same everywhere, so I was not mistaken. Topic hash for swaps from step 3
0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822

Step 4. Use the topic hash information to find the total number of SWAPS on each of the top 2 token pairs for the first week of April 2021.Use the Get Log events by topic hash(es) Covalent API endpoint https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/events/topics/{topic}/.In terms of your query parameters:- topic is your topic hash from a previous hint- For the sender-address, ask what address is issuing the Swap event- Use a large page-size value (i.e. 99999) just to ensure you get all the data

We are almost at the goal, it remains to collect the information and make a request using the Covalent API.

At the very beginning, the task gave clear deadlines — April 2021 from April 1, 00: 00: 00 UTC until April 7, 23:59: 59 UTC.

Now we need to find the blocks for these dates to search for the necessary information within these blocks. If you remember, we’ve done this before in Round 1.

Just like last time, we use https://avascan.info/blockchain/c/blocks and look for the necessary dates.

I found the first block from the beginning of April — https://avascan.info/blockchain/c/block/875518.

And the second block, which is required by the condition.
https://avascan.info/blockchain/c/block/1009864

So, we have two blocks:

875 518

1 009 864

And so, it would seem, what else? Oh, yes, in the query string, we have a certain sender-address.

Initially, I was sure that this is the address specified in the logs. It was because of this that my request was constantly interrupted and was incorrect. And again, thanks to the help in the Covalent discord, I finally realized that this line should contain the Smart Contract address of the desired pair. When the logic hit me, I felt like an idiot! It’s so obvious :)

First, I inserted the PNG/ WAVAX address and copied it as usual in Excel — CSV format. Unfortunately, the request turned out to be heavy, so I had to wait for a little while, while it was processing.

After copying it to Excel, I was in a hurry to solve the task faster, so I made the mistake of counting each row as a new swap, but if you look closely, you can see that one swap is several lines. As a result, I noticed that each swap is unique with the topic hash that is already familiar to us, so I performed a search in Excel for this indicator and got the number 6833.

Now we had to do the same thing, only for the USDT/ WAVAX address.
After identical actions, I got the second number — 5346

So, the most difficult part is over. We have two numbers.

6833

5346

We are waiting for the last, fifth step.

Step 5. Once you have found the total number of swaps, convert this to hexadecimal.Your secret room with the next task will be unlocked at the website: www.onemillionwallets.com/{hexadecimal_number}

The task stated that: The sum of these numbers must be converted to the hexadecimal system. Any online converter can handle this task.

6833+5346=12179

The result is 2f93.

And we have the right link!

https://www.onemillionwallets.com/2f93

Hooray! I’m back in the secret room!

After such a difficult test, the secret room task seemed like a child’s warm-up.

Finding the specified words is no problem.

The task is still available at the link, go ahead and try to do it as quickly as possible!

By tradition, I wrote a tweet about this event!

You know what to do :)

It was the most difficult round, which would have been easier if I had paid more attention. However, the most valuable thing is the skills and knowledge that I gained while solving this quest.

Thanks to the Covalent API, extracting data from the blockchain for subsequent analytics becomes easier than ever and is available to absolutely any user.

Just try it!

We still have one last round, in which I felt much more confident, and I will tell you about it very soon.

See you later!

--

--