A decentralized camera system for verifiable and authentic digital photography
- Overview
- Key Features
- System Architecture
- Getting Started
- Usage Guide
- Technical Documentation
- Development
- Troubleshooting
- Contributing
- License
- Quick Start with Automated Script
BlockSnap revolutionizes digital photography by combining blockchain technology with image capture to create verifiable and tamper-proof photographs. Each image captured through BlockSnap is:
- Captured securely through hardware integration
- Stored permanently on IPFS (InterPlanetary File System)
- Minted as an NFT on the Ethereum blockchain
- Verifiable for authenticity and ownership
In an era of deepfakes and digital manipulation, BlockSnap provides:
- Authenticity: Cryptographic proof of original images
- Ownership: Clear digital rights management through NFTs
- Immutability: Tamper-proof storage on blockchain
- Transparency: Public verification system
- 📰 Photojournalism: Verify news photo authenticity
- ⚖️ Legal Documentation: Tamper-proof evidence
- 🎨 Art Authentication: Prove digital art originality
- 📸 Professional Photography: Protect image rights
- 🏛️ Historical Documentation: Preserve authentic records
-
Secure Image Capture
- Direct hardware integration with Raspberry Pi Camera
- GPS location tagging (optional)
- Timestamp verification
- Resolution control
-
Decentralized Storage
- IPFS integration for permanent storage
- Content-addressed data
- Optional Pinata pinning service
- Redundant storage
-
Blockchain Integration
- ERC-721 NFT standard
- Metadata storage
- Ownership tracking
- Public verification
-
Web3 Features
- MetaMask wallet integration
- Gas optimization
- Network configuration
- Transaction management
-
Frontend
- Real-time camera preview
- Gallery view
- Verification interface
- Responsive design
- Dark/Light themes
-
Backend
- RESTful API
- IPFS node management
- Blockchain interaction
- Error handling
- Logging system
graph TD
A[Frontend - React] --> B[Backend - Flask]
B --> C[IPFS Network]
B --> D[Ethereum Network]
E[Camera Module] --> B
F[GPS Module] --> B
BlockSnap/
├── backend/
│ ├── app.py # Flask application
│ ├── blockchain_handler.py # Ethereum interactions
│ ├── ipfs_handler.py # IPFS operations
│ ├── camera_handler.py # Hardware control
│ └── utils/ # Helper functions
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Application pages
│ │ ├── hooks/ # Custom React hooks
│ │ ├── context/ # React context
│ │ └── utils/ # Helper functions
│ └── public/ # Static assets
├── smart_contracts/
│ ├── BlockSnapNFT.sol # Main NFT contract
│ └── test/ # Contract tests
├── hardware/
│ ├── camera.py # Camera implementation
│ └── gps.py # GPS implementation
└── scripts/
├── deploy.js # Contract deployment
└── verify.js # Contract verification
-
Raspberry Pi
- Model 4B (2GB+ RAM) or 3B+
- MicroSD card (16GB+)
- Power supply (3A)
-
Camera Module
- Raspberry Pi Camera Module v2
- or compatible camera
-
Optional Hardware
- GPS Module (for location tagging)
- Touchscreen display
- GPIO buttons
-
Operating System
- Raspberry Pi OS (64-bit)
- or Ubuntu 22.04+
-
Development Tools
-
Python 3.11+
- Node.js 16+
- npm/yarn
- Git
-
Blockchain Tools
- MetaMask
- Hardhat
- IPFS
-
System Setup
git clone <repository-url> cd BlockSnap
-
Set up Python environment:
conda create -n blocksnap python=3.11 conda activate blocksnap pip install -r requirements.txt
-
Install Node.js dependencies:
# Clone repository git clone https://github.com/yourusername/BlockSnap.git cd BlockSnap # Setup Python environment python -m venv venv source venv/bin/activate pip install -r requirements.txt # Setup frontend cd frontend npm install
-
Start IPFS daemon:
ipfs daemon
-
Configure environment:
cp .env.example .env
Update
.env
with your configuration:# Ethereum Network Configuration ETH_RPC_URL=https://rpc.buildbear.io/impossible-omegared-15eaf7dd CONTRACT_ADDRESS=<your-contract-address> PRIVATE_KEY=<your-private-key> # IPFS Configuration IPFS_HOST=/ip4/127.0.0.1/tcp/5001 IPFS_GATEWAY=https://ipfs.io USE_PINATA=false PINATA_API_KEY=your_pinata_api_key PINATA_SECRET_KEY=your_pinata_secret_key # Hardware Configuration CAMERA_RESOLUTION=1920x1080 SHUTTER_PIN=17 LED_PIN=27 USE_GPS=false GPS_PORT=/dev/ttyUSB0
-
Compile contract:
npx hardhat clean npx hardhat compile
-
Deploy to BuildBear:
npx hardhat run scripts/deploy.js --network buildbear
-
Update
CONTRACT_ADDRESS
in.env
-
Start backend server:
conda activate blocksnap /home/hrithik/miniconda3/envs/blocksnap/bin/python main.py
-
Start frontend:
npm start
-
Access the app at
http://localhost:3000
- 📸 Web-based photo capture
- 🖼️ IPFS storage with local node or Pinata
- 🎨 NFT minting for each photo
- 🗃️ Gallery view with IPFS integration
- 📋 One-click IPFS CID copying
- ⛓️ Blockchain verification
- 🔐 MetaMask wallet integration
-
Initial Setup
- Install BlockSnap
- Configure environment
- Deploy smart contract
- Start services
-
Taking Photos
sequenceDiagram participant User participant Camera participant IPFS participant Blockchain User->>Camera: Capture Photo Camera->>IPFS: Upload Photo IPFS-->>Camera: Return CID Camera->>Blockchain: Mint NFT Blockchain-->>User: Confirm Transaction
-
Viewing Gallery
- Connect wallet
- Browse captured photos
- View metadata
- Download originals
-
Verifying Photos
- Input IPFS CID
- Check blockchain record
- View ownership history
- Verify metadata
Capture and mint new photo
Request:
{
"wallet_address": "0x...",
"image_data": "base64_string"
}
Response:
{
"status": "success",
"data": {
"token_id": "1",
"ipfs_cid": "Qm...",
"tx_hash": "0x..."
}
}
Verify photo authenticity
Response:
{
"verified": true,
"owner": "0x...",
"timestamp": "2024-12-26T10:00:00Z",
"metadata": {
"location": "...",
"device": "..."
}
}
function mintPhoto(
address to,
string memory imageCID,
string memory metadataURI
) public returns (uint256)
function verifyPhoto(
string memory imageCID
) public view returns (bool, address)
-
Start IPFS
ipfs daemon
-
Start Backend
conda activate blocksnap /home/hrithik/miniconda3/envs/blocksnap/bin/python main.py
-
Start Frontend
npm start
# Smart Contract Tests
npx hardhat test
# Backend Tests
pytest
# Frontend Tests
npm test
-
IPFS Connection
- Check daemon status
- Verify port accessibility
- Check network connectivity
-
BuildBear Network Issues
- Verify RPC URL is correct and accessible
- Ensure chainId is set to 22566
- Check if the network is responsive
- Verify contract deployment status
-
Camera Problems
- Enable camera interface
- Check permissions
- Verify hardware connection
We welcome contributions! Please see our Contributing Guide for details.
- Fork repository
- Create feature branch
- Commit changes
- Push to branch
- Submit pull request
- Python: Follow PEP 8
- JavaScript: ESLint config
- Solidity: Solidity style guide
- Documentation: JSDoc/docstrings
MIT License - See LICENSE file for details
We provide an automated script to simplify the startup process:
-
First-time setup:
./run.sh --setup
This will:
- Create the conda environment
- Install Python dependencies
- Install Node.js dependencies
-
Regular startup:
./run.sh
This will automatically:
- Start IPFS daemon
- Start the Flask backend server
- Launch the React frontend
- Set up all necessary connections
-
Access the application:
- Frontend: http://localhost:3000
- Backend: http://localhost:5000
- IPFS Gateway: http://localhost:8080
-
Stop all services:
- Press Ctrl+C in the terminal running the script
- The script will gracefully shut down all services
The script includes:
- Dependency checks
- Environment setup
- Port management
- Process cleanup
- Error handling