0xBreak/NftCharity
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Β | Β | |||
Β | Β | |||
Repository files navigation
## π Features - **ERC721 Compliant**: Full implementation of ERC721 standard with metadata extension - **Automatic Fund Distribution**: Built-in percentage-based revenue sharing across multiple wallets - **Multiple Minting Options**: Individual mint, batch mint, and self-mint functions - **Flexible Metadata**: Support for both base URI and individual token URIs - **Security Features**: Reentrancy protection and comprehensive access controls - **Admin Functions**: Complete administrative control over contract parameters ## π Fund Distribution The contract automatically distributes mint proceeds across four wallets: | Wallet Type | Percentage | Purpose | |-------------|------------|---------| | π₯ Charity | 40% | Charitable donations | | π± Eco Development | 30% | Environmental initiatives | | β½ Gas & Marketing | 20% | Operational costs | | π€ Owner | 10% | Contract owner | ## π Quick Start ### Prerequisites - Solidity ^0.8.20 - Node.js and npm - Hardhat or Truffle for deployment ### Installation ```bash # Clone the repository git clone https://github.com/ZeroNewLife/NftCharity cd rocknft-contract # Install dependencies npm install ``` ### Deployment ```solidity constructor( string memory name_, // "RockNFT Collection" string memory symbol_, // "ROCK" address _charityWallet, // 0x... address _ecoDevWallet, // 0x... address _gasAndMarketingWallet, // 0x... string memory baseTokenURI_ // "https://api.example.com/metadata/" ) ``` ## π Contract Interface ### Minting Functions #### `mintNFT(address to, string memory tokenURI_)` Mint an NFT with custom metadata URI. - **Parameters**: Recipient address, custom token URI - **Cost**: 0.01 ETH (adjustable) - **Access**: Public (payable) ```solidity // Example usage contract.mintNFT( "0x56bF24eE384BC70cB52C2352448149a2f4Dd7e1B", "https://api.example.com/token/1" ); ``` #### `mint(address to)` Simple mint function using base URI. - **Parameters**: Recipient address - **Cost**: 0.01 ETH (adjustable) - **Access**: Public (payable) #### `mintToSelf()` Mint NFT to caller's address. - **Cost**: 0.01 ETH (adjustable) - **Access**: Public (payable) #### `batchMintOwner(address[] recipients, string[] tokenURIs_)` Batch mint multiple NFTs (owner only). - **Parameters**: Array of recipients, array of token URIs - **Cost**: Free (owner function) - **Access**: Owner only ### Administrative Functions #### Wallet Management ```solidity setCharityWallet(address newCharityWallet) setEcoDevWallet(address newEcoDevWallet) setGasAndMarketingWallet(address newGasMarketingWallet) setOwnerWallet(address newOwnerWallet) ``` #### Contract Parameters ```solidity setMintPrice(uint256 newPrice) // Update mint price setMaxSupply(uint256 newMaxSupply) // Update maximum supply setBaseURI(string memory newBaseURI) // Update base metadata URI ``` #### Emergency Functions ```solidity emergencyWithdraw() // Withdraw all contract funds transferOwnership(address newOwner) // Transfer contract ownership ``` ## π View Functions ### Contract Information ```solidity getContractInfo() returns ( string contractName, string contractSymbol, uint256 currentPrice, uint256 currentSupply, uint256 maximumSupply, address contractOwner ) ``` ### Distribution Information ```solidity getDistributionInfo() returns ( uint256 charityPercent, uint256 ecoDevPercent, uint256 gasMarketingPercent, uint256 ownerPercent, address charity, address ecoDev, address gasMarketing, address ownerAddr ) ``` ### Token Information ```solidity getTokenInfo(uint256 tokenId) returns ( address owner_, string tokenURI_, bool exists ) ``` ## π‘οΈ Security Features - **Reentrancy Protection**: All minting functions protected against reentrancy attacks - **Access Control**: Owner-only functions with proper modifiers - **Safe Transfers**: Built-in checks for successful fund transfers - **Input Validation**: Comprehensive validation of all inputs ## π± Integration Examples ### Web3.js Integration ```javascript const Web3 = require('web3'); const web3 = new Web3('YOUR_PROVIDER_URL'); const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS); // Mint NFT await contract.methods.mintToSelf().send({ from: userAddress, value: web3.utils.toWei('0.01', 'ether'), gas: 200000 }); // Get contract info const info = await contract.methods.getContractInfo().call(); console.log('Current supply:', info.currentSupply); ``` ### Ethers.js Integration ```javascript const { ethers } = require('ethers'); const contract = new ethers.Contract(CONTRACT_ADDRESS, ABI, signer); // Mint NFT with custom URI const tx = await contract.mintNFT( recipient, "https://api.example.com/token/123", { value: ethers.utils.parseEther("0.01") } ); await tx.wait(); ``` ## π§ͺ Testing ```bash # Run tests npm test # Run with coverage npm run coverage # Deploy to testnet npm run deploy:testnet ``` ## π Gas Estimates | Function | Estimated Gas | |----------|---------------| | `mintToSelf()` | ~120,000 | | `mintNFT()` | ~140,000 | | `batchMintOwner()` (5 NFTs) | ~400,000 | | `setMintPrice()` | ~30,000 | ## π Supported Networks - Ethereum Mainnet - Polygon - BSC - Avalanche - Arbitrum - Optimism ## π License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## π€ Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/AmazingFeature`) 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request ## π Bug Reports If you discover any bugs, please create an issue with: - Detailed description of the bug - Steps to reproduce - Expected vs actual behavior - Screenshots (if applicable) ## π Support - π§ Email: workzero02@gmail.com - π¦ Twitter: [@RockNFT](https://x.com/ZeroNewLif) ## π Roadmap - [ ] Layer 2 deployment - [ ] Royalty implementation (EIP-2981) - [ ] Upgradeable proxy pattern - [ ] Advanced metadata features - [ ] Integration with major marketplaces --- **β οΈ Disclaimer**: This smart contract has not been audited. Use at your own risk. Always test thoroughly on testnets before mainnet deployment.