Skip to content

Latest commit

 

History

History
216 lines (162 loc) · 5.72 KB

File metadata and controls

216 lines (162 loc) · 5.72 KB

🧠 MemChain - Decentralized Memory Storage

A decentralized memory storage system that combines IPFS (InterPlanetary File System) with blockchain technology for permanent and immutable data storage.

Features

  • 📁 File Upload: Upload any type of file (text, images, documents, audio, video)
  • 🌐 IPFS Storage: Files are stored on IPFS for decentralized access
  • ⛓️ Blockchain Recording: File hashes and metadata are stored on Polygon blockchain
  • 📊 Analytics: Visual analytics showing upload patterns and memory types
  • 🔍 Memory Browser: View and access all previously stored memories
  • 🎨 Modern UI: Choose between Streamlit (web) or Tkinter (desktop) interface

Prerequisites

  1. IPFS Node: You need to have IPFS running locally

    # Install IPFS from https://ipfs.io/
    ipfs daemon
  2. Environment Variables: Create a .env file with:

    PRIVATE_KEY=your_polygon_private_key
    PUBLIC_KEY=your_polygon_public_address
    WEB3_PROVIDER_URI=https://polygon-amoy.g.alchemy.com/v2/YOUR_API_KEY
    
  3. Contract Deployment: Deploy the smart contract first:

    python deploy_contract.py

Installation

  1. Clone and Install Dependencies:
    cd memchain
    pip install -r requirements.txt

Usage

Quick Start

python launch_gui.py

This will give you options to choose between:

  1. Streamlit Interface (Modern web-based) - Recommended
  2. Tkinter Interface (Traditional desktop)

Streamlit Interface (Recommended)

Features:

  • 🎨 Modern, responsive web interface
  • 📊 Interactive charts and analytics
  • 📱 Works on mobile devices
  • 🔄 Real-time updates
  • 🌈 Beautiful visualizations

To run directly:

streamlit run gui_app.py

Access: Open http://localhost:8501 in your browser

Tkinter Interface

Features:

  • 🖥️ Native desktop application
  • 📦 No additional dependencies
  • ⚡ Fast and lightweight
  • 🔒 Works offline (except blockchain operations)

To run directly:

python tkinter_app.py

How It Works

  1. Select File: Choose any file from your computer

  2. Choose Memory Type: Categorize your memory (text, image, document, etc.)

  3. Upload Process:

    • File is uploaded to IPFS
    • IPFS hash is generated
    • Transaction is sent to Polygon blockchain
    • Memory is permanently recorded
  4. View Memories: Browse all stored memories with direct IPFS access links

File Types Supported

  • 📄 Text: .txt, .md, .json, etc.
  • 🖼️ Images: .jpg, .png, .gif, etc.
  • 📊 Documents: .pdf, .doc, .docx, etc.
  • 🎵 Audio: .mp3, .wav, etc.
  • 🎥 Video: .mp4, .avi, etc.
  • 📁 Any file type up to 16MB

Architecture

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│   Python    │    │    IPFS     │    │  Polygon    │
│     GUI     │───▶│   Storage   │───▶│ Blockchain  │
│             │    │             │    │             │
└─────────────┘    └─────────────┘    └─────────────┘
  1. Frontend: Streamlit/Tkinter GUI for user interaction
  2. Storage: IPFS for decentralized file storage
  3. Blockchain: Polygon Amoy testnet for metadata and hash storage
  4. Smart Contract: Solidity contract managing memory records

Smart Contract Functions

  • saveMemory(string ipfsHash, string memoryType): Store a new memory
  • getMemory(uint256 id): Retrieve memory details
  • memoryCount(): Get total number of memories stored

Network Information

Commands Reference

Command Line Scripts

# Upload file to IPFS only
python upload_ipfs.py

# Save IPFS hash to blockchain
python save_memory.py

# Deploy smart contract
python deploy_contract.py

GUI Applications

# Launch GUI selector
python launch_gui.py

# Direct Streamlit launch
streamlit run gui_app.py

# Direct Tkinter launch
python tkinter_app.py

Troubleshooting

Common Issues

  1. IPFS Connection Error

    Solution: Make sure IPFS daemon is running
    Command: ipfs daemon
    
  2. Blockchain Connection Error

    Solution: Check your .env file and network settings
    
  3. Contract Not Found

    Solution: Deploy the contract first
    Command: python deploy_contract.py
    

Streamlit Issues

  • Port Already in Use: Change port with streamlit run gui_app.py --server.port 8502
  • Browser Not Opening: Manually go to http://localhost:8501

Tkinter Issues

  • GUI Not Showing: Make sure you have tkinter installed (usually comes with Python)
  • Threading Issues: Close and restart the application

Development

Project Structure

memchain/
├── gui_app.py          # Streamlit web interface
├── tkinter_app.py      # Tkinter desktop interface
├── launch_gui.py       # GUI launcher
├── upload_ipfs.py      # IPFS upload utility
├── save_memory.py      # Blockchain save utility
├── deploy_contract.py  # Contract deployment
├── requirements.txt    # Python dependencies
├── .env               # Environment variables
└── contracts/
    └── MemoryStore.sol # Smart contract

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test with both GUI interfaces
  5. Submit a pull request

💡 Tip: Use the Streamlit interface for the best experience with rich visualizations and analytics!