This project showcases an NFT marketplace smart contract that leverages the Chainlink testnet oracle to make API requests from CryptoCompare. The oracle fetches the latest ETH price in USD, allowing users to list NFTs for sale in USD, with the payment converted to ETH at the time of the transaction. The marketplace takes a 10% commission from each successful trade, which is transferred to the admin (contract deployer).
- BUY NFT
- Listed and Owned NFTs
- Owned NFTs
- Oracle Integration: Uses Chainlink testnet oracle to get the latest ETH price in USD from CryptoCompare.
- NFT Listing: Users can list their NFTs for sale in USD.
- ETH Payment: Buyers are charged in ETH equivalent to the USD price at the time of the sale.
- Admin Commission: 10% commission from each successful trade goes to the wallet that deployed the contract.
- The GRAPH: Uses The Graph to index all NFTs and provides a GraphQL schema for querying.
- Solidity: Smart contract development.
- Vite: Frontend build tool.
- React: Frontend framework.
- TypeScript: Type-safe JavaScript.
- The Graph: Indexing protocol for querying blockchain data.
- ethers.js: Library for interacting with the Ethereum blockchain.
- Hardhat: Ethereum development environment.
- Node.js and npm installed.
- A GitHub account to clone the repository.
- Access to the Sepolia testnet.
- Pinata account for IPFS storage.
-
Clone the repository
git clone https://github.com/capsy14/NFT-MarketPlace cd NFT-MarketPlace
-
Install Dependencies
npm install
-
Create an .env file
- In the project root, create a .env file with the following content:
SEPOLIA_URL=<Your_Sepolia_Testnet_URL> VITE_PINATA_API_KEY=<Your_Pinata_API_Key> VITE_PINATA_SECRET_API_KEY=<Your_Pinata_Secret_API_Key> VITE_PUBLIC_GRAPH_URL=<Your_GraphQL_API_URL> VITE_NFT_MARKET_ADDRESS=<Your_NFT_Marketplace_Contract_Address>
-
Install Graph CLI
npm install -g @graphprotocol/graph-cli
-
Create a Subgraph
graph init --product hosted-service <GITHUB_USER>/<SUBGRAPH_NAME>
-
Configure Subgraph
Update the subgraph.yaml file with the necessary configurations including the contract address and ABI.
-
Deploy Subgraph
graph auth --product hosted-service <ACCESS_TOKEN> graph deploy --product hosted-service <GITHUB_USER>/<SUBGRAPH_NAME>
-
Start the development server
npm run dev
- NFT Marketplace The smart contract allows users to list NFTs for sale and buyers to purchase them using ETH. The listing price is specified in USD, and the contract uses the Chainlink oracle to fetch the current ETH/USD exchange rate to determine the equivalent ETH amount. Upon a successful purchase, 10% of the sale price is sent to the admin.
- Commission The contract is designed to take a 10% commission from every sale, which is automatically transferred to the admin's address.
- GraphQL Integration The project uses The Graph to index all NFTs. This allows efficient querying of NFT data through a GraphQL API. The schema includes the necessary types and queries to fetch NFT details, listings, and sale information.
Test the project at : NFTMarketPlace
Made by Kartik Bhatt