/TONQuest6

Primary LanguageTypeScript

TON Speedrun

🚩 Challenge 6: Analyzing NFT sales on the Getgems marketplace

🎫 Analyzing NFT sales on the Getgems marketplace. We will get information about sales through get-methods of smart contracts

🌟 Script that will return the latest sales from the marketplace and distinguish between types of sales.

💬 Meet other builders working in TON and get help in the official dev chat or TON learn tg


Checkpoint 0: 📦 Install 📚

Required:

(⚠️ Don't install the linux package yarn make sure you install yarn with npm i -g yarn or even sudo npm i -g yarn!)

git clone https://github.com/romanovichim/TONQuest6.git
cd challenge-6
yarn install

Checkpoint 1: 🔬 Analyze Logic 😮

Understanding how smart contracts work, you can get almost any information from the network. In TON, the actor model, respectively, in order to understand where to get information, you need to understand the chain of smart contracts.

Let's try to go this way for the Getgems marketplace, take some NFT and, moving from it, try to find the information we need.

In this quest, you have to search a lot for addresses in the TON network, if you have problems with this, at the end of each script there will be a hint - the correct address with which the script will work - but this is an extreme case.


Checkpoint 2: 📡 Search for Marketplace Contract 📡

So we have a clean slate in front of us and we need to start from something. The simplest thing seems to be to take the address of the NFT from the marketplace and try to look at it in detail.

Go to https://getgems.io/ and search any NFT collection, make sure that NFT has sales (history at the very bottom of the page) Example:

image

Find Getgems Marketplace in the sales contract

image

As you can understand, royalties from each sale come here, which means that we can track all sales of the Getgems marketplace, getting the addresses of smart contracts for the sale from the transactions of the Getgems marketplace contract, and then take information about the sale.

Run the script and check in the exporter https://tonscan.org/ that the transactions are correct.

yarn getmarketplace

Result:

image


Checkpoint 3: 👩‍🚀 Search for Types of sales 👩‍🚀

Now we have all the sales, but they are different, I’ll tell you right away that Getgems have:

  • Simple Sale
  • Offer
  • Auction

By making requests to the Getmethods of these smart contracts, you can get information about what NFT is being sold for and at what price. Get methods they have the following:

  • Simple Sale - get_sale_data()
  • Offer - get_offer_data()
  • Auction - get_sale_data()

Find all three types of addresses in the marketplace transactions in the scripts below and run them:

Simple Sale:

yarn getsale

Offer:

yarn getoffer

Auction:

yarn getauction

Checkpoint 4:🎩 Query last sales 🎩

Let's collect everything we learned in past checkpoints and display information about the last NFTs sold

yarn getnftsold

Result:

image

Cool, but not enough, an additional script that would display at the NFT address what kind of collection and NFT would be in place.


⚔️ Side Quests

Quick results are great, but to play longer, enjoy the ecosystem, I suggest you the following tutorials:

🏆 Reward

Congratulations on successfully completing this challenge! Before we conclude, let's take a quick look at the exciting reward awaiting you from the "TON Speedrun" collection:

Ready to claim your reward? Just scan the QR code, which can be generated using the script below:

yarn reward