ConsentChain is a decentralized consent management platform built on Algorand blockchain. It enables secure, transparent, and efficient management of data sharing consents between individuals and institutions.
- ConsentContract.py: Core smart contract for managing consents
- Request consent
- Grant consent
- Revoke consent
- View document permissions
- Expiry management
- Role-based access control
-
Authentication & Wallet Integration
- Pera Wallet integration
- QR code-based wallet connection
- Session management
- Role-based routing
-
Consent Management Interface
- Request consent form
- Grant consent dashboard
- Consent history view
- Document viewer
- Permission management
-
User Dashboard
- Active consents
- Pending requests
- Document library
- Activity logs
- Settings management
-
Reusable UI Components
InputandTextArea: Standardized form input fields.Pill: For displaying status labels.Toggle: An animated on/off switch.Spinner: A loading indicator for async operations.Modal: A generic modal/dialog component.
-
Algorand Service (
algorandConsentService.js)- Smart contract interaction
- Transaction management
- Account management
- State verification
-
IPFS Service (
ipfsService.js)- Document storage
- Content addressing
- Metadata management
-
MongoDB Service (
mongoService.js)- User data storage
- Consent records
- Activity logs
- Analytics data
-
Telegram Bot Service (
telegramBotService.js)- Notification system
- Consent alerts
- Status updates
# ConsentContract.py
- approval_program(): Main contract logic
- clear_state_program(): State clearing logic
- Key operations:
- request_consent()
- grant_consent()
- revoke_consent()
- view_document()src/
βββ components/
β βββ ConsentRecord.tsx # Consent display component
β βββ DigiLocker.tsx # Document management
β βββ WalletConnect.js # Wallet integration
β βββ animations/ # UI animations
βββ pages/
β βββ Dashboard.js # Main dashboard
β βββ GrantConsent.js # Consent granting
β βββ RequestConsent.js # Consent requesting
β βββ ViewConsent.js # Consent viewing
βββ services/ # Backend services
A brief overview of the key directories in the frontend application:
-
Consent Management Utilities (
src/utils/consentHelpers.js)- Validation functions for consent requests
- Formatting utilities for consent records
- ID generation and expiry checking
- Permission formatting helpers
-
Consent Statistics Component (
src/components/ConsentStats.js)- Real-time analytics dashboard
- Visual progress bars and metrics
- Status-based filtering and display
- Responsive design with Tailwind CSS
-
Notification Service (
src/services/notificationService.js)- Browser notification support
- Real-time alerts for consent events
- Customizable notification types
- Click handlers and auto-dismissal
-
Consent State Management Hook (
src/hooks/useConsent.js)- Comprehensive consent CRUD operations
- State management with React hooks
- Error handling and loading states
- Integration with notification service
src/
βββ api/ # Functions for interacting with the backend API
βββ assets/ # Static assets like images and SVGs
βββ components/ # Reusable React components (Buttons, Modals, etc.)
βββ constants/ # Application-wide constants
βββ contexts/ # React context providers for global state
βββ hooks/ # Custom React hooks
βββ layouts/ # Layout components (e.g., main app layout with Navbar)
βββ pages/ # Top-level page components for each route
βββ services/ # Services for interacting with external APIs (Algorand, IPFS)
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ App.tsx # Main application component with routing
βββ index.tsx # Application entry point
server/
βββ index.js # Main server
βββ models/
β βββ consentRequest.js # Data models
βββ services/ # Business logic
- Node.js (v18.17.0 or as specified in
.nvmrc) - Python 3.8+
- An Algorand Testnet Account with funds
-
Clone the repository:
git clone https://github.com/YashDiwan-16/algorand.git cd algorand -
Install Python dependencies:
cd contracts pip install -r requirements.txt -
Set up environment variables:
- Navigate to the
contractsdirectory. - Copy
.env.exampleto a new file named.env. - Fill in your
CREATOR_MNEMONICandRECIPIENT_MNEMONIC.
- Navigate to the
-
Deploy the contracts:
python deploy.py
-
Install frontend dependencies: (From the root
algoranddirectory)npm install
-
Start the development servers: This command starts both the React frontend and the Express backend concurrently.
npm run dev
The application will be available at
http://localhost:3000.
- Secure sharing of medical records
- Patient consent management
- HIPAA compliance
- Research data sharing
- Academic record verification
- Certificate sharing
- Student data management
- Institution collaboration
- Document verification
- Background check consent
- Employee data management
- HR process automation
- Identity document sharing
- Personal data management
- Privacy control
- Data portability
-
Blockchain Security
- Immutable consent records
- Transparent audit trail
- Cryptographic verification
- Smart contract security
-
Data Protection
- End-to-end encryption
- IPFS content addressing
- Secure key management
- Access control
-
Privacy Controls
- Granular permissions
- Time-limited access
- Revocation capabilities
- Data minimization
# Run frontend tests
npm test
# Run smart contract tests
python contracts/scripts/test.py
# Run integration tests
npm run test:integration# Deploy to mainnet
python contracts/scripts/deploy.py --network mainnet
# Build frontend
npm run build
# Deploy frontend
npm run deploy# Request Consent
request_consent(document_hash, document_type, request_id, requester)
# Grant Consent
grant_consent(expiry, permissions)
# Revoke Consent
revoke_consent()
# View Document
view_document()// Consent Management
POST /api/consent/request
GET /api/consent/:id
PUT /api/consent/:id/grant
DELETE /api/consent/:id
// Document Management
POST /api/document/upload
GET /api/document/:id
DELETE /api/document/:id
// User Management
GET /api/user/profile
PUT /api/user/settings- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Algorand Foundation
- Pera Wallet Team
- React Community
- TailwindCSS Team
ConsentChain now offers a seamless integration with Telegram! You can interact with the platform directly from your favorite messaging app using our official bot:
- Bot Username: @consent_bot
- Features:
- Manage your data consents
- Receive real-time notifications
- Approve or reject requests
- And moreβall from Telegram!
To get started, visit the new Telegram Bot page in the app navigation or click here.
Visit the new Telegram Bot page in the app or go to @consent_bot on Telegram. Follow the instructions to link your account and manage your data consents directly from Telegram.