A decentralized NFT marketplace built on Ethereum with creator royalties and secondary sales support.
- ERC-721 NFT Standard - Full compatibility with all NFT platforms
- Creator Royalties - Automatic royalty payments on secondary sales (up to 10%)
- Marketplace Functions - List, unlist, buy, and make offers on NFTs
- Secure - Built with OpenZeppelin contracts and ReentrancyGuard
- Gas Optimized - Efficient smart contract design
- 2.5% Marketplace Fee - Sustainable platform economics
- Solidity ^0.8.20
- Hardhat (Development Framework)
- OpenZeppelin Contracts
- Ethers.js
- Mocha & Chai (Testing)
mintNFT(tokenURI, royalty)- Create new NFT with royalty percentagelistNFT(tokenId, price)- List NFT for saleunlistNFT(tokenId)- Remove NFT from marketplacebuyNFT(tokenId)- Purchase listed NFTmakeOffer(tokenId)- Make offer on any NFTacceptOffer(tokenId, offerIndex)- Accept an offercancelOffer(tokenId, offerIndex)- Cancel your offer
getTokensByOwner(address)- Get all tokens owned by addressgetListedNFTs()- Get all listed NFTs in marketplacegetTotalNFTs()- Get total minted NFTsgetCreator(tokenId)- Get original creatorgetRoyalty(tokenId)- Get royalty percentage
- Contract Address:
0xfFd322FBe14c824b3E8f25e69a68156bd4c4059C - Network: Sepolia (Chain ID: 11155111)
- Explorer: View on Etherscan
- Node.js v16+
- npm or yarn
- MetaMask wallet
# Clone the repository
git clone <your-repo-url>
cd nft-project-clean
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Add your PRIVATE_KEY and SEPOLIA_RPC_URL
Environment Variables
Create a .env file:
envPRIVATE_KEY=your_private_key_here
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
Never commit your .env file or expose private keys!
Testing
bash# Run all tests
npx hardhat test
# Run tests with gas reporting
REPORT_GAS=true npx hardhat test
# Run tests with coverage
npx hardhat coverage
Deployment
Deploy to Sepolia Testnet
bashnpx hardhat run scripts/deploy.js --network sepolia
Verify Contract (Optional)
bashnpx hardhat verify --network sepolia DEPLOYED_CONTRACT_ADDRESS
Project Structure
nft-project-clean/
├── contracts/
│ └── DecentraArt.sol # Main NFT marketplace contract
├── scripts/
│ └── deploy.js # Deployment script
├── test/
│ └── DecentraArt.test.js # Test suite
├── hardhat.config.js # Hardhat configuration
└── README.md
Security
Audited OpenZeppelin contracts
ReentrancyGuard protection
Ownership controls
Comprehensive test coverage
Gas Optimization
The contract is optimized for gas efficiency:
Minimal storage operations
Efficient loops
Batch operations where possible
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For questions and support, please open an issue in the GitHub repository.
Disclaimer
This is a testnet deployment for educational and demonstration purposes. Use at your own risk.