• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Chiliz

Introduction
Chiliz Network and Its Use Cases
What Are Test Tokens and How to Utilize Them

What Are We Going to Build
Which Technologies Will Be Used
Implementing Frontend I - Creating ENV
Implementing Frontend II - Connect Wallet
Implementing Frontend III - Getting Token Balances
Implementing Frontend IV - Getting Token Metadata
Implementing Frontend V - HTML/CSS Walkthrough
Homework I - Submit your github repository link

What Are We Going to Build
Getting Chiliz Testnet Coins
Deploying NFT Marketplace Using Thirdweb
Implementing Frontend I - Creating ENV
Implementing Frontend II - Fetching Contract Info
Implementing Frontend III - Interacting with NFT Collection
Implementing Frontend IV - Interacting with Marketplace
Implementing Frontend V - List/Delist NFT on Marketplace
Implementing Frontend VI - Buy Listing
Homework II - Submit your github repository link

Submit Your Final Project

Building the NFT Marketplace Index Page with Buy Functionality

In this video, we implemented the Index Page of our NFT marketplace. This page displays all the listed NFTs available for sale, including their metadata and a “Buy” button to allow users to purchase NFTs directly from the marketplace.

1. Index Page Overview

The index page is designed to:

  • Display listed NFTs in a grid layout
  • Show each NFT’s image, name, description, and price
  • Include a "Buy" button for eligible listings

We use the ListingCard component to render each NFT listing dynamically.

2. Fetching Marketplace Listings

To load active listings:

  • We use getMarketplaceContract() to retrieve the contract instance.
  • Then, we call useContract with the Marketplace V3 identifier.
  • We query only valid listings using pagination (start: 0, count: 100).
const { contract: marketplace } = useContract(getMarketplaceAddress(), "marketplace-v3");
  • We check if listings are loading and conditionally display a loading message.
  • Once available, we map over the listings and render ListingCard components with relevant NFT data.

3. Displaying NFT Metadata

Each ListingCard displays:

  • Image from nft.asset.image
  • Name from nft.asset.name
  • Description from nft.asset.description
  • Price and symbol from nft.currencyValuePerToken.displayValue and nft.currencyValuePerToken.symbol

We use a custom image tag and format values manually for a responsive layout.

4. Implementing the "Buy" Button Logic

Unlike other interactions, buying an NFT does not have a dedicated Thirdweb hook, so we handle it manually.

Steps:

Retrieve the listing using the marketplace contract:

const listing = await marketplace.directListings.getListing(nft.asset.id);
  1. Prevent users from buying their own NFTs by comparing the listing creator address to the connected wallet address.

Handle the buying process with:

await marketplace.directListings.buyFromListing(listing.id, 1);

Wrap everything in a try-catch block to manage errors gracefully:

try {
  setMessage("Buying...");
  const result = await buyFunction();
  if (result.receipt) {
    setMessage("Bought!");
  }
} catch (error) {
  console.error(error);
  setMessage("Error buying!");
}
  1. Display user feedback via the message state throughout the transaction process.

5. Managing Loading and Error States

We show:

  • "Buying..." during the transaction
  • "Bought!" if successful
  • "Error buying!" if it fails
  • "Already yours!" if a user tries to buy their own listing

This enhances the user experience and prevents broken flows.

6. Summary

In this implementation:

  • We fetched valid marketplace listings
  • Rendered detailed NFT cards with buy functionality
  • Implemented a custom buy interaction using Thirdweb’s SDK
  • Managed state and UI for errors, success, and invalid cases

With the Index Page now functional, users can view and purchase NFTs seamlessly from the decentralized marketplace.

Previous
Next

Lesson discussion

Swap insights and ask questions about “Learn everything about Chiliz”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved