DEV Community

Cover image for Telegram NFT Auctions (Fragment) with C#
Mehran Davoudi
Mehran Davoudi

Posted on

Telegram NFT Auctions (Fragment) with C#

In my project, I needed to connect to fragment.com and read some information about the auctioned numbers in it. So, I started with my favorite language, C#! In this blog post, I will introduce the C# SDK that I've created to connect to Fragment and read its information in a fully typed way. First, let me explain what Fragment is and why it’s important. Then I’ll show you how I created the SDK. Finally, I’ll include some code snippets and screenshots to make it easier for you to follow along.

What is Fragment?

Telegram is definitely my absolute favorite messaging app ever! It has a feature called Anonymous Number, which are unique phone numbers that can be used to login to Telegram fully anonymously.

That's where fragment.com comes in. Fragment is a decentralized marketplace that runs on The Open Network (TON), a blockchain platform that was initially developed by Telegram's founders.

Fragment

Fragment allows users to bid for Telegram Anonymous Numbers and Usernames in an auction format. All usernames are represented on the TON blockchain as non-fungible tokens (NFTs), meaning they are unique and indivisible digital assets.

How to Use Fragment SDK?

To access the data from Fragment in a convenient and efficient way, I decided to create a .NET SDK that can communicate with the TON blockchain and parse the information from Fragment. The result is TonRadar.Fragment nuget package, which you can install in your project using the following command:

dotnet add package TonRadar.Fragment
Enter fullscreen mode Exit fullscreen mode

Here is an example of how to use the SDK to get the details of the current highest bid for the username "ton":

// Create an instance of the FragmentClient class auctions.
var client = new FragmentClient();

// Reading all auctions with EndingSoon filter.
var auctionItems = await client.Numbers.GetAuctionsItemsAsync(SortType.EndingSoon);

// Reading all for-sale items.
var saleItems = await client.Numbers.GetSaleItemsAsync(FilterType.ForSale);

// Reading all sold items.
var soldItems = await client.Numbers.GetSoldItemsAuctionsAsync(FilterType.Sold);
Enter fullscreen mode Exit fullscreen mode

Conclusion

In this blog post, I have shown you how to use my C# SDK, TonRadar.Fragment, to access and analyze the data from Fragment. For now, I've just added my needed methods to the library. But in the future, I'll add more functionality to it. I will be more than happy if you contribute and add you're required features to it and send some pull requests. You can find the repo here on GitHub.

Fragment .NET SDK on GitHub

Top comments (0)