Skip to content

sebahattinn/DigitalWillApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Will & Inheritance System

A blockchain-based, AI-assisted mobile application for managing digital wills and inheritance using Flutter, Solidity, and Deep Learning.

Overview

This MVP allows users to:

  • Create secure digital wills stored on Ethereum blockchain
  • Assign crypto assets, NFTs, and social media accounts to beneficiaries
  • Use AI to suggest beneficiaries based on social connections
  • Automated inactivity detection with human verification
  • End-to-end encryption with IPFS storage

Architecture

┌─────────────────┐
│  Flutter App    │
│  (Mobile UI)    │
└────────┬────────┘
         │
    ┌────┴────────────────────┐
    │                         │
┌───▼──────┐         ┌───────▼────────┐
│ Web3     │         │ ML Inference   │
│ Service  │         │ Service        │
└───┬──────┘         └───────┬────────┘
    │                        │
┌───▼──────────┐    ┌────────▼────────┐
│ Smart        │    │ TFLite Model    │
│ Contract     │    │ (Inactivity     │
│ (Solidity)   │    │  Classifier)    │
└──────────────┘    └─────────────────┘
         │
    ┌────▼─────────────┐
    │  IPFS Storage    │
    │  (Encrypted)     │
    └──────────────────┘

Quick Start

Prerequisites

  1. Flutter SDK (3.0.0+)

    flutter --version
  2. Node.js & npm (for Hardhat)

    node --version
    npm --version
  3. Python 3.8+ (for ML model training)

    python --version
  4. Metamask or similar Web3 wallet

Installation

1. Clone Repository

git clone https://github.com/yourusername/digital-will-app.git
cd digital-will-app

2. Install Flutter Dependencies

flutter pub get

3. Setup Smart Contract

cd contracts
npm install

Create .env file:

SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
PRIVATE_KEY=your_wallet_private_key
ETHERSCAN_API_KEY=your_etherscan_key

Compile and deploy:

npx hardhat compile
npx hardhat run scripts/deploy.js --network sepolia

Save the deployed contract address!

4. Train ML Model

cd ml_models
pip install -r requirements.txt
python inactivity_classifier.py

This generates:

  • inactivity_model.h5 (Keras model)
  • scaler.pkl (Feature scaler)

5. Convert Model to TFLite

python convert_to_tflite.py

Copy inactivity_model.tflite to assets/ml_models/

6. Configure API Keys

Create lib/core/config/api_config.dart:

class APIConfig {
  static const String sepoliaRpcUrl = 'YOUR_ALCHEMY_URL';
  static const String contractAddress = 'YOUR_CONTRACT_ADDRESS';
  static const String pinataAPIKey = 'YOUR_PINATA_KEY';
  static const String pinataSecretKey = 'YOUR_PINATA_SECRET';
  static const String facebookAppId = 'YOUR_FB_APP_ID';
}

7. Run the App

flutter run

Project Structure

digital_will_app/
├── lib/
│   ├── core/
│   │   ├── config/          # API configs
│   │   ├── constants/       # App constants
│   │   └── utils/           # Helper functions
│   ├── data/
│   │   ├── models/          # Data models
│   │   ├── repositories/    # Data repositories
│   │   └── services/        # Business logic
│   │       ├── web3_service.dart
│   │       ├── encryption_service.dart
│   │       ├── ipfs_service.dart
│   │       ├── ml_inference_service.dart
│   │       └── social_media_service.dart
│   ├── presentation/
│   │   ├── screens/         # UI screens
│   │   │   ├── create_will_screen.dart
│   │   │   ├── dashboard_screen.dart
│   │   │   └── verification_screen.dart
│   │   └── widgets/         # Reusable widgets
│   └── main.dart
├── contracts/
│   ├── DigitalWill.sol      # Smart contract
│   ├── hardhat.config.js
│   └── scripts/
│       └── deploy.js
├── ml_models/
│   ├── inactivity_classifier.py
│   ├── convert_to_tflite.py
│   └── requirements.txt
├── assets/
│   ├── ml_models/
│   │   └── inactivity_model.tflite
│   ├── images/
│   └── contracts/
│       └── DigitalWill.json  # ABI
└── test/

Configuration

Blockchain (Testnet for MVP)

// hardhat.config.js
module.exports = {
  solidity: "0.8.20",
  networks: {
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL,
      accounts: [process.env.PRIVATE_KEY],
      chainId: 11155111
    }
  }
};

IPFS Configuration

Option 1: Pinata (Recommended)

Option 2: Infura IPFS

Social Media OAuth

Facebook/Instagram:

  1. Create app at https://developers.facebook.com
  2. Add OAuth redirect URIs
  3. Request permissions: user_posts, user_likes
  4. Add App ID to config

Testing

Smart Contract Tests

cd contracts
npx hardhat test

Flutter Tests

flutter test

ML Model Evaluation

cd ml_models
python test_model.py

Features

MVP Features (6 weeks)

  • User registration & authentication
  • OAuth integration (Facebook/Instagram)
  • Digital asset management UI
  • Will creation flow
  • Beneficiary assignment
  • Rule-based inactivity detection
  • Smart contract deployment (testnet)
  • IPFS encrypted storage
  • Basic ML classifier
  • Push notifications for verification

Future Features (Post-MVP)

  • Multi-chain support (Polygon, BSC)
  • Advanced ML model with LSTM
  • Multi-source verification (notary API)
  • Family tree integration
  • Legal document templates
  • Asset auto-discovery
  • Multi-signature support
  • DAO governance for disputes

Security

Encryption

  • AES-256 encryption for sensitive data
  • End-to-end encryption
  • Client-side key management
  • Secure key storage with Flutter Secure Storage

Smart Contract Security

  • ReentrancyGuard protection
  • Access control modifiers
  • Tested with Hardhat
  • Auditable on-chain logic

Privacy

  • GDPR/KVKK compliant
  • Explicit user consent
  • Data deletion rights
  • Minimal metadata storage

ML Model Details

Features (18 dimensions)

  • Days since last post/like/comment/DM
  • Activity frequency metrics
  • Engagement rates
  • Device usage patterns
  • Posting consistency
  • Social network density

Architecture

Input (18) → Dense(128) → BatchNorm → Dropout(0.3)
         → Dense(64) → BatchNorm → Dropout(0.3)
         → Dense(32) → Dropout(0.2)
         → Output(3): [active, suspicious, deceased]

Performance (on synthetic data)

  • Accuracy: ~92%
  • AUC-ROC: ~0.96
  • Precision (deceased class): ~88%

Gas Costs (Sepolia Testnet)

Operation Estimated Gas Cost (ETH)
Create Will ~250,000 ~0.002
Update Will ~80,000 ~0.0008
Record Activity ~45,000 ~0.0004
Execute Will ~120,000 ~0.001

Troubleshooting

Common Issues

1. Web3 Connection Failed

// Check RPC URL and network
await _client.getNetworkId(); // Should return 11155111 for Sepolia

2. IPFS Upload Timeout

// Try different gateway or increase timeout
options: Options(receiveTimeout: Duration(seconds: 30))

3. ML Model Not Loading

// Ensure .tflite file is in assets and pubspec.yaml is updated
flutter clean && flutter pub get

4. Smart Contract Call Reverts

# Check if wallet has testnet ETH
# Get free ETH from Sepolia faucet: https://sepoliafaucet.com

API Documentation

Web3Service

// Create new will
await web3Service.createWill(
  encryptedDataURI: ipfsHash,
  beneficiaryAddresses: ['0x...', '0x...'],
  sharePercentages: [5000, 5000], // 50%, 50% (basis points)
  inactivityThreshold: 15552000, // 180 days in seconds
);

// Record activity (resets inactivity timer)
await web3Service.recordActivity();

// Check inactivity status
bool isInactive = await web3Service.checkInactivity(ownerAddress);

// Get will data
Map<String, dynamic> willData = await web3Service.getWillData(ownerAddress);

IPFSService

// Upload encrypted will
String ipfsHash = await ipfsService.uploadWillData({
  'assets': [...],
  'beneficiaries': [...],
  'metadata': {...}
});

// Retrieve will data
Map<String, dynamic> willData = await ipfsService.retrieveWillData(ipfsHash);

// Pin for persistence
await ipfsService.pinContent(ipfsHash);

MLInferenceService

// Predict activity status
Map<String, dynamic> prediction = await mlService.predictActivityStatus({
  'days_since_last_post': 45,
  'days_since_last_like': 30,
  'app_sessions_per_week': 2,
  // ... other features
});

// Output:
// {
//   'active': 0.15,
//   'suspicious': 0.65,
//   'deceased': 0.20,
//   'recommendation': 'REQUEST_VERIFICATION',
//   'confidence': 0.65
// }

SocialMediaService

// Get activity metadata
Map<String, dynamic> metadata = await socialService.calculateActivityMetadata();

// Fetch recent posts
List<Map<String, dynamic>> posts = await socialService.fetchRecentPosts(limit: 50);

// Analyze patterns
double consistency = socialService.analyzePostingConsistency(posts);

Workflow

Will Creation Flow

graph TD
    A[User Opens App] --> B[Connect Wallet]
    B --> C[OAuth Social Login]
    C --> D[Add Digital Assets]
    D --> E[Add Beneficiaries]
    E --> F{Use AI Suggestions?}
    F -->|Yes| G[Analyze Social Graph]
    F -->|No| H[Manual Entry]
    G --> I[Set Inactivity Threshold]
    H --> I
    I --> J[Encrypt Will Data]
    J --> K[Upload to IPFS]
    K --> L[Create Smart Contract]
    L --> M[Transaction Confirmed]
    M --> N[Will Active]
Loading

Inactivity Detection Flow

graph TD
    A[Daily Cron Job] --> B[Check All Active Wills]
    B --> C{Fetch User Activity}
    C --> D[Social Media API]
    C --> E[App Usage Logs]
    D --> F[Calculate Features]
    E --> F
    F --> G[ML Model Prediction]
    G --> H{Status?}
    H -->|Active| I[Update Timestamp]
    H -->|Suspicious| J[Send Verification Request]
    H -->|Deceased| K[Count Failed Verifications]
    K --> L{3+ Failed?}
    L -->|Yes| M[Mark as Deceased]
    L -->|No| J
    J --> N[User Responds?]
    N -->|Yes| I
    N -->|No| K
    M --> O[Execute Will]
Loading

Deployment Checklist

Pre-Production

  • Complete security audit of smart contracts
  • Penetration testing of backend APIs
  • Load testing (1000+ concurrent users)
  • Legal compliance review (inheritance laws)
  • Privacy policy & terms of service
  • KYC/AML integration (if handling large assets)
  • Multi-sig wallet for contract ownership
  • Backup & disaster recovery plan

Mainnet Deployment

# 1. Audit smart contract
npm run audit

# 2. Deploy to mainnet
npx hardhat run scripts/deploy.js --network mainnet

# 3. Verify contract on Etherscan
npx hardhat verify --network mainnet DEPLOYED_CONTRACT_ADDRESS

# 4. Update app config with mainnet details
# 5. Submit app to stores (App Store, Play Store)

Monitoring & Analytics

Key Metrics

User Metrics:

  • Active wills created
  • Average assets per will
  • Verification response rate
  • User retention (30/60/90 day)

System Metrics:

  • ML model accuracy (production)
  • False positive rate (deceased detection)
  • Smart contract gas optimization
  • IPFS retrieval latency

Business Metrics:

  • User acquisition cost
  • Lifetime value
  • Conversion rate (free → paid)
  • Churn rate

Tools

# monitoring-stack.yml
services:
  - Firebase Analytics (user behavior)
  - Sentry (error tracking)
  - Mixpanel (product analytics)
  - Grafana + Prometheus (system metrics)
  - The Graph (blockchain indexing)

Cost Estimation

Monthly Operating Costs (MVP, 1000 users)

Service Cost
Firebase (Auth, Notifications) $25
Pinata IPFS (100GB) $20
Alchemy API (Ethereum RPC) $49
Server (Node.js backend) $50
ML Model Hosting $30
Total ~$174/month

Per-User Costs

  • Gas fees: ~$5-10 (one-time, paid by user)
  • Storage: ~$0.02/month
  • API calls: ~$0.05/month

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Fork the repo
git clone https://github.com/YOUR_USERNAME/digital-will-app.git

# Create feature branch
git checkout -b feature/amazing-feature

# Make changes and test
flutter test

# Commit with conventional commits
git commit -m "feat: add beneficiary auto-suggestion"

# Push and create PR
git push origin feature/amazing-feature

Code Style

  • Follow Effective Dart
  • Use flutter format before commits
  • Write tests for new features
  • Document public APIs

License

This project is licensed under the MIT License - see LICENSE file.

Disclaimer

Important Legal Notice:

This is an MVP project for educational and demonstration purposes. Before using in production:

  1. Legal Compliance: Inheritance laws vary by jurisdiction. Consult with legal experts in your target markets.

  2. Not Financial Advice: This system does not provide legal, financial, or estate planning advice.

  3. Smart Contract Risks: Blockchain transactions are irreversible. Thoroughly test and audit before mainnet deployment.

  4. Privacy: Implement proper GDPR/CCPA compliance for user data handling.

  5. Death Verification: The inactivity detection is NOT a substitute for official death certificates. Implement multi-source verification with legal authorities.

  6. Liability: Users should understand the risks of crypto custody and inheritance planning.

Support

Acknowledgments

  • OpenZeppelin for smart contract libraries
  • TensorFlow team for ML framework
  • IPFS for decentralized storage
  • Ethereum Foundation
  • Flutter community

Roadmap

Q1 2025

  • MVP launch (testnet)
  • Core features implementation
  • Security audit
  • Beta testing (100 users)

Q2 2025

  • Mainnet deployment
  • iOS/Android app store launch
  • Multi-chain support (Polygon)
  • Advanced ML model (LSTM)

Q3 2025

  • Legal partnerships (notaries)
  • Enterprise features
  • API for third-party integrations
  • Mobile web version

Q4 2025

  • International expansion
  • Fiat on-ramp integration
  • DAO governance launch
  • White-label solution

Built with using Flutter, Solidity & Deep Learning

Version: 1.0.0-mvp
Last Updated: October 2025

Additional Resources

Learning Resources

Blockchain Development:

Flutter Development:

Machine Learning:


Star this repo if you find it useful!

About

my graduation thesis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors