#Ethereum
#SEPOLIA
#NEXT.JS
#SUBGRAPH
`
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
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.
The user can perform the following actions on this NFT Marketplace:
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.
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.
Sellers can cancel their listed NFTs, removing them from the marketplace. The NFT is then transferred back to the seller.
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.
Sellers can remove the current arbiter from the listed NFT at any time.
Users can buy NFTs from the marketplace by paying the price in ETH currency to the marketplace.
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.
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.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
---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 thisREADME.md
. - Then setup your frontend using
nft-marketplace-frontend
folder.
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
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.
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
Before builidng your subgraph and deploying it to subgraph studio make sure you have deployed your contract and verified it on etherscan (sepolia).
- follow this Quick Start to initialize, create, and deploy your subgraph to Subgraph Studio.
- After creating you subgraph just copy the code from
schema.graphql
andsubgraph-indexer/src/nft-market-place.ts
and paste to the respective files in your subgraph before deploying it to subgraph studio.
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
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",
start your next app using :
$ yarn run dev
Tadda... Your frontend will start on localhost.