# MustaFair CARV ID Files

A collection of CARV ID implementation files for decentralized social media platforms, featuring modular identity management, reputation systems, and Web2 achievement integration.

## Installation

```bash
npm install mustafair-carvid
```

## Usage

After installation, you can copy the files directly into your project:

```bash
# Copy components to your project
cp -r node_modules/mustafair-carvid/components ./src/

# Copy contracts to your hardhat project
cp -r node_modules/mustafair-carvid/contracts ./hardhat/

# Copy utilities and ABIs
cp -r node_modules/mustafair-carvid/lib ./src/
cp -r node_modules/mustafair-carvid/hooks ./src/
```

## File Structure

```
mustafair-carvid/
├── components/              # React components
│   ├── MintCarvIdDialog.tsx
│   ├── carv-id-viewer.tsx
│   ├── carv-id-login.tsx
│   ├── identity-graph.tsx
│   ├── rep-nft-minter.tsx
│   └── identity-wallet-linker.tsx
├── contracts/               # Smart contracts
│   ├── ModularCarvID.sol
│   ├── ReputationNFT.sol
│   └── CarvIdPostVoting.sol
├── artifacts/               # Contract artifacts and ABIs
├── lib/                     # Utilities and ABIs
│   ├── ModularCarvID_ABI.json
│   ├── ReputationNFT_ABI.json
│   ├── CarvIdPostVoting_ABI.json
│   ├── identity-hash.ts
│   ├── carv-id-provider.ts
│   └── fair3-reputation-sdk.ts
├── hooks/                   # Custom hooks
│   └── use-identity-wallet-binding.ts
└── README.md               # This file
```

## Components

### MintCarvIdDialog
Mint new CARV ID NFTs with Web2 achievement integration.

### CarvIdPassportDialog
View and manage existing CARV ID profiles.

### IdentityGraph
Visualize identity connections and relationships.

### RepNftMinter
Mint reputation NFTs for governance participation.

### IdentityWalletLinker
Link OAuth identities to Web3 wallets via ERC-7231.

## Smart Contracts

The package includes the following smart contracts:

- **ModularCarvID.sol**: Core CARV ID implementation
- **ReputationNFT.sol**: Reputation and governance system
- **CarvIdPostVoting.sol**: Decentralized voting system

## Utilities

### Identity Hash Generation
```typescript
import { generateIdentityHash, parseIdentityData } from './lib/identity-hash';

const identityData = parseIdentityData('github', profile, Date.now());
const hash = generateIdentityHash(identityData);
```

### CARV ID Provider
```typescript
import { CarvIdProvider } from './lib/carv-id-provider';

// Use with NextAuth
const authOptions = {
  providers: [
    CarvIdProvider,
    // ... other providers
  ],
};
```

## Configuration

### Environment Variables

```env
NEXT_PUBLIC_CONTRACT_ADDRESS=0x...
NEXT_PUBLIC_REPUTATION_NFT_ADDRESS=0x...
NEXT_PUBLIC_POST_VOTING_ADDRESS=0x...
```

### Network Support

- BNB Testnet (Chain ID: 97)
- Localhost (Chain ID: 1337)

## Dependencies

The components require these dependencies in your project:

```json
{
  "dependencies": {
    "ethers": "^6.0.0",
    "wagmi": "^1.0.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "next-auth": "^4.0.0",
    "sonner": "^1.0.0",
    "lucide-react": "^0.400.0",
    "@radix-ui/react-dialog": "^1.0.0",
    "@radix-ui/react-button": "^1.0.0",
    "@radix-ui/react-card": "^1.0.0",
    "@radix-ui/react-alert": "^1.0.0",
    "@radix-ui/react-badge": "^1.0.0"
  }
}
```

## Development

### Publishing Updates
```bash
# Update version
npm version patch

# Publish
npm publish
```

## License

MIT License - see LICENSE file for details.

## Support

For issues and questions, please open an issue on the GitHub repository.
