Skip to content

0xBreak/NftCharity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors