Skip to content

tusharr1411/nft-marketplace-ethereum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Ethereum #SEPOLIA #NEXT.JS #SUBGRAPH `

NFT Marketplace

An open decentralized NFT Marketplace built on ethereum (sepolia) smartcontract. It is an open platform where users can buy and sell their NFTs

Demo : Link

Get some sepolia ETH : Chainlink faucet or Alchemy faucet

Project Description

The user can access the marketplace using this Link, and he must have the Metamask or any other wallet installed. This interface, built with next.js, relies on the Moralis library to communicate with the smart contracts through Metamask. The data reflected on the front-end application is fetched from the marketplace contract events which are indexed using subgraph-indexer.

NFT Marketplace features

The user can perform the following actions on this NFT Marketplace:

List NFT

Sellers can list their NFTs for sale on the marketplace. They fill out a form providing the NFT contract address, token ID, and the listing price in USD. Ownership of the NFT is verified using the ownerOf function of the NFT smart contract. If the seller is the owner, the marketplace contract is approved to transfer the NFT. The NFT is then listed on the marketplace with the specified USD price.

Update Listing

Users can update the price of an already listed NFT. If the user updates the listing price and the listing has an arbiter who was added within the last 24 hours, the arbiter will get an additional 24 hours to raise a dispute.

Cancel Listing

Sellers can cancel their listed NFTs, removing them from the marketplace. The NFT is then transferred back to the seller.

Add Arbiter

Sellers can add an arbiter to a listed NFT. The arbiter will have 24 hours to dispute the listing. If there is already an arbiter who was added more than 24 hours ago, only then can the seller change the arbiter.

Remove Arbiter

Sellers can remove the current arbiter from the listed NFT at any time.

Buy NFT

Users can buy NFTs from the marketplace by paying the price in ETH currency to the marketplace.

Raise Dispute

Arbiters can raise a dispute for a listed NFT if they are the arbiter for that listing and they were added as the arbiter within the last 24 hours.

Withdraw

Sellers can withdraw their proceeds from selling NFTs. The owner of the marketplace can also withdraw the commissions (10%) earned from others' sales on the marketplace.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

The repository

---nft-marketplace-backend  : is the backend directory which is hardhat project 
                              and contains smartcontract for marketplace
---nft-marketplace-frontend : is contains client side code & subgraph indexer
        |---frontend-graph  : is the nextjs app folder
        |---subgraph        : is a subgraph project made for listening the 
                              quering blockchain events.

clone or fork the repository into your Github account:

$ git clone https://github.com/tusharr1411 nft-marketplace-ethereum

Follow these instructions to setup the projects:

  • First Setup the & deploy the smartcontract using nft-marketplace-backend. Follow this README.md.
  • Then setup your frontend using nft-marketplace-frontend folder.
    • Before starting next app you need to build and deploy to subgraph studio using nft-marketplace-backend/subgraph-indexer. Follow this README.md.
    • start your frontend app using nft-marketplace-backend/frontend-graph folder. Follow this README.md.

1. nft-marketplace-backend [Hardhatprojet]

After cloning the https://github.com/tusharr1411/nft-marketplace-ethereum repo locally.

navigate to the backend repo using :

$ cd nft-marketplace-ethereum/nft-marketplace-backend

Installing

After that install the dependencies with: yarn or npm.

$ yarn

or

$ npm install

Then rename the example.env to .env and add values of enviornment variables inside this file.

Deploying

To deploy smartcontract on testnet or mainnet ( let say sepolia) use these commands :

$ yarn hardhat deploy

Tadda... Your marketplace contract and a basic NFT will be deployed and varified on the etherscan. And also the frontend constants will be written in the frontend directory.

You can interact with NftMarketplace.sol smartcontract on sepolia etherscan using it's address or just build your own frontend app using this README.md


2. subgraph-indexer [subgraph studio]

Before builidng your subgraph and deploying it to subgraph studio make sure you have deployed your contract and verified it on etherscan (sepolia).


3 frontend-graph [NextJS]

Note : Before getting start make sure you have deployed your NftMarketplace contract using this README.md and have build your and deployed subgraph for event listening using subgraph-indexer folder ( use this README.md)

Navigate to the frontend-graph repo using :

$ cd nft-marketplace-ethereum/nft-marketplace-frontend/frontend-graph

Installing

Install the dependencies with: yarn or npm.

$ yarn

or

$ npm install

Then rename the example.env to .env and add the values of .env variables ( Not needed actually)

And change this line in _app.js according to your subgraph api link.

uri: "https://api.studio.thegraph.com/query/66907/lync-nft-marketplace-2024/version/latest",

Starting App

start your next app using :

$ yarn run dev

Tadda... Your frontend will start on localhost.