{"id":23384935,"url":"https://github.com/dhruv-varshney-developer/advanced-nft","last_synced_at":"2025-04-08T11:25:13.690Z","repository":{"id":265655917,"uuid":"895939370","full_name":"Dhruv-Varshney-developer/advanced-nft","owner":"Dhruv-Varshney-developer","description":"A Solidity-based NFT project featuring Merkle Tree airdrops, bitmap optimizations, commit-reveal randomness, multicall, state-driven minting, and pull-pattern withdrawals. Built with OpenZeppelin libraries, it prioritizes security, scalability, and gas efficiency.","archived":false,"fork":false,"pushed_at":"2024-11-30T10:20:45.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T07:39:44.999Z","etag":null,"topics":["airdrop","commit-reveal","merkle-proof","merkle-tree","multicall","nft","openzeppelin","randomness","smart-contracts","solidity","statemachine"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dhruv-Varshney-developer.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T08:17:36.000Z","updated_at":"2024-11-30T10:23:32.000Z","dependencies_parsed_at":"2024-12-01T16:31:52.241Z","dependency_job_id":null,"html_url":"https://github.com/Dhruv-Varshney-developer/advanced-nft","commit_stats":null,"previous_names":["dhruv-varshney-developer/advanced-nft"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dhruv-Varshney-developer%2Fadvanced-nft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dhruv-Varshney-developer%2Fadvanced-nft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dhruv-Varshney-developer%2Fadvanced-nft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dhruv-Varshney-developer%2Fadvanced-nft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dhruv-Varshney-developer","download_url":"https://codeload.github.com/Dhruv-Varshney-developer/advanced-nft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247831468,"owners_count":21003387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airdrop","commit-reveal","merkle-proof","merkle-tree","multicall","nft","openzeppelin","randomness","smart-contracts","solidity","statemachine"],"created_at":"2024-12-21T23:34:01.195Z","updated_at":"2025-04-08T11:25:13.672Z","avatar_url":"https://github.com/Dhruv-Varshney-developer.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Advanced NFT\n\n## Description\n\nThis project implements an **advanced NFT contract** with cutting-edge features such as **Merkle Tree-based airdrops**, **bitmap optimizations**, **commit-reveal random allocation**, **multicall for efficient transfers**, and a **state machine to control minting phases**. The project is designed for scalability, security, and gas efficiency, leveraging OpenZeppelin libraries.\n\n## Features\n\n### 1\\. **Merkle Tree Airdrop**\n\n- Addresses in the Merkle Tree are allowed to mint NFTs during the presale.\n- The contract supports two tracking mechanisms:\n\n  - **Mapping**: A traditional approach using a mapping to track addresses.\n  - **Bitmap**: A gas-optimized method using OpenZeppelin’s BitMaps.\n\n### 2\\. **Commit-Reveal Mechanism**\n\n- Ensures randomness during the NFT allocation process.\n- Users commit a hash (NFT ID + secret) and reveal it after a delay of 10 blocks.\n- Inspired by Cool Cats NFT but implemented without Chainlink.\n\n### 3\\. **Multicall**\n\n- Enables batch processing of NFT transfers in a single transaction.\n- Prevents abuse by ensuring only allowed functions can be multicalled.\n\n### 4\\. **State Machine**\n\n- The contract operates in distinct phases:\n\n  - **Paused**: No minting allowed.\n  - **Presale**: Merkle Tree-based minting using mapping or bitmap.\n  - **Public Sale**: Commit-reveal minting and multicall allowed.\n  - **Sold Out**: Minting disabled.\n\n- Each phase is enforced using require statements.\n\n### 5\\. **Pull-Pattern Fund Withdrawal**\n\n- Contributors can withdraw funds individually using the **pull pattern**, improving security.\n- Allows withdrawals to multiple contributors.\n\n### 6\\. **Gas Optimizations**\n\n- Utilizes bitmap tracking for airdrop eligibility to reduce storage costs.\n- Leverages OpenZeppelin’s nonReentrant modifier to prevent reentrancy attacks.\n\n## File Structure\n\n```bash\n\nAdvancedNFT/\n├── contracts/\n│   └── advancednft.sol         # Main NFT contract implementation\n├── merkletree/\n│   ├── merkleproof.mjs         # Script to generate Merkle Tree and proofs\n│   ├── tree.json               # Serialized Merkle Tree data\n│   ├── package.json            # Dependencies for the Merkle Tree scripts\n│   └── .gitignore              # Ignore unnecessary files\n├── answers.md                  # Answers to important questions\n├── README.md                   # Documentation for the project\n\n```\n\n## Installation\n\n### Prerequisites\n\n- **Node.js**: To run the Merkle Tree scripts.\n- **Solidity Compiler**: For compiling the contract.\n\n### Steps\n\n1.  Clone the repo:\n\n```bash\nclone https://github.com/username/AdvancedNFT.git\ncd AdvancedNFT\n```\n\n2.  Generate merkletree and proof or use existing ones.:\n\n```bash\ncd merkletree\nnpm install\n```\n\n3.  Deploy the contract using **Hardhat** or **Remix**.\n\n## Usage\n\n### 1\\. **Generating Merkle Proofs**\n\nRun the `merkleproof.mjs` script to generate the Merkle Root and proofs:\n\n```bash\nnode merkletree/merkleproof.mjs\n```\n\nUse the generated root and proofs in the contract.\n\n### 2\\. **Minting During Presale**\n\nUse `mintWithMapping` or `mintWithBitmap` with a valid Merkle Proof.\n\n### 3\\. **Commit-Reveal in Public Sale**\n\n- Get commit hash:\n  Use the following command in the console to generate the commit hash:\n\n  ```javascript\n  web3.utils.keccak256(\n    web3.eth.abi.encodeParameters(\n      [\"uint256\", \"uint256\"],\n      [replace_with_nftId, replace_with_secret]\n    )\n  );\n  ```\n\n- Commit:\n\n```solidity\ncommit(hash);\n```\n\n- Reveal (after 10 blocks):\n\n```solidity\nreveal(nftId, secret);\n```\n\n### 4\\. **Batch Transfers**\n\nPrepare calldata using generateTransferFromData and call multicall with the encoded data.\n\n### 5\\. **Withdrawing Funds**\n\nContributors can call withdraw() to claim their funds securely.\n\n## Tools and Libraries\n\n- **OpenZeppelin Contracts**: Security and gas-efficient libraries.\n- **Hardhat**: Testing and deployment.\n- **Merkle Tree Utilities**: For secure airdrops.\n- **Solidity 0.8.x**: Latest features with built-in overflow checks.\n\n## Contributing\n\n1.  Fork the repository.\n2.  `git checkout -b feature-name`\n3.  Submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruv-varshney-developer%2Fadvanced-nft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhruv-varshney-developer%2Fadvanced-nft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhruv-varshney-developer%2Fadvanced-nft/lists"}