Zum Inhalt

⛓️ Blockchain Architecture

Stand: 25. Oktober 2025
Version: 1.0
Purpose: Forever-Functional Licensing System


🎯 ARCHITECTURE OVERVIEW

┌──────────────────────────────────────────────────────────┐
│  Solana Blockchain (Payment & NFT Licensing)             │
├──────────────────────────────────────────────────────────┤
│  - Payment Processing (USDC/SOL)                         │
│  - NFT Minting (License Tokens)                          │
│  - Ownership Verification                                │
│  - Transaction Fees: ~$0.00025                           │
└──────────────────────────────────────────────────────────┘
         ▲                                    │
         │ Payment                            │ NFT Minted
         │                                    ▼
┌──────────────────────────────────────────────────────────┐
│  User Wallet (Phantom / Solflare)                        │
├──────────────────────────────────────────────────────────┤
│  - Holds License NFTs                                    │
│  - Signs Transactions                                    │
│  - Connects to Web Apps                                  │
└──────────────────────────────────────────────────────────┘
         │ Wallet Connect
┌──────────────────────────────────────────────────────────┐
│  Arweave Blockchain (Permanent Storage)                  │
├──────────────────────────────────────────────────────────┤
│                                                           │
│  Web Apps (Forever Functional):                          │
│  ├─ ESP32 Flasher Tool v1.0 (TX: abc123...)             │
│  ├─ Pi Image Builder v1.0 (TX: def456...)               │
│  └─ License Verifier (SmartWeave)                       │
│                                                           │
│  Firmware Binaries:                                      │
│  ├─ ESP32_v1.0.bin (TX: ghi789...)                      │
│  ├─ ESP32_v1.1.bin (TX: jkl012...)                      │
│  └─ ESP32_v2.0.bin (TX: mno345...)                      │
│                                                           │
│  Cost: ~$0.005 per file (FOREVER!)                      │
│  Availability: 200+ years guaranteed                     │
│                                                           │
└──────────────────────────────────────────────────────────┘
         │ HTTP Gateway (arweave.net)
┌──────────────────────────────────────────────────────────┐
│  User's Browser                                           │
├──────────────────────────────────────────────────────────┤
│  - Loads Web App from Arweave                            │
│  - Connects Phantom Wallet                               │
│  - Verifies License NFT                                  │
│  - Downloads Firmware                                    │
│  - Flashes ESP32 via WebSerial                          │
└──────────────────────────────────────────────────────────┘

💎 SOLANA SMART CONTRACT

NFT License Token (Metaplex Standard)

// Solana Program (Rust)
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Mint, Token, TokenAccount};

#[program]
pub mod solarlog_licensing {
    use super::*;

    // Mint Pi Image License NFT
    pub fn mint_pi_license(
        ctx: Context<MintLicense>,
        license_key: String,
        arweave_tx: String,
        esp32_credits: u8,
    ) -> Result<()> {
        let license = &mut ctx.accounts.license;
        license.owner = *ctx.accounts.buyer.key;
        license.license_type = LicenseType::PiImage;
        license.license_key = license_key;
        license.arweave_tx = arweave_tx;
        license.esp32_credits = esp32_credits;
        license.activated_at = Clock::get()?.unix_timestamp;
        license.version = "1.0".to_string();

        // Mint NFT Token
        token::mint_to(
            ctx.accounts.into_mint_to_context(),
            1, // 1 NFT
        )?;

        Ok(())
    }

    // Use ESP32 Flash Credit
    pub fn use_esp32_credit(
        ctx: Context<UseCredit>,
        device_id: String,
    ) -> Result<()> {
        let license = &mut ctx.accounts.license;

        require!(license.esp32_credits > 0, ErrorCode::NoCreditsLeft);
        require!(license.owner == *ctx.accounts.user.key, ErrorCode::Unauthorized);

        license.esp32_credits -= 1;

        // Log device activation
        emit!(DeviceActivated {
            license_key: license.license_key.clone(),
            device_id,
            credits_remaining: license.esp32_credits,
            timestamp: Clock::get()?.unix_timestamp,
        });

        Ok(())
    }

    // Verify License Ownership
    pub fn verify_license(
        ctx: Context<VerifyLicense>,
    ) -> Result<bool> {
        let license = &ctx.accounts.license;

        Ok(license.owner == *ctx.accounts.user.key && license.esp32_credits > 0)
    }
}

#[account]
pub struct License {
    pub owner: Pubkey,
    pub license_type: LicenseType,
    pub license_key: String,
    pub arweave_tx: String,
    pub esp32_credits: u8,
    pub activated_at: i64,
    pub version: String,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Eq)]
pub enum LicenseType {
    PiImage,
    Esp32Flash,
    Enterprise,
}

#[error_code]
pub enum ErrorCode {
    #[msg("No ESP32 credits left")]
    NoCreditsLeft,
    #[msg("Unauthorized: Not license owner")]
    Unauthorized,
}

#[event]
pub struct DeviceActivated {
    pub license_key: String,
    pub device_id: String,
    pub credits_remaining: u8,
    pub timestamp: i64,
}

📦 ARWEAVE SMARTWEAVE CONTRACT

License Verification (JavaScript)

// Arweave SmartWeave Contract
// Deployed to: TX abc123def456...

export function handle(state, action) {
  const { input, caller } = action;

  // Verify License Ownership (calls Solana)
  if (input.function === 'verifyLicense') {
    const { solanaAddress, deviceId } = input;

    // Check Solana blockchain for NFT ownership
    // (In practice: Arweave reads from Solana via Oracle)
    const hasLicense = state.licenses[solanaAddress] || false;

    if (!hasLicense) {
      throw new ContractError('No valid license found');
    }

    // Check ESP32 credits
    const credits = state.credits[solanaAddress] || 0;

    if (credits <= 0) {
      throw new ContractError('No ESP32 credits available');
    }

    // Consume credit
    state.credits[solanaAddress] -= 1;

    // Register device (anti-fraud)
    state.devices[deviceId] = {
      owner: solanaAddress,
      activatedAt: Date.now(),
      version: input.version || '1.0'
    };

    return {
      state,
      result: {
        success: true,
        creditsRemaining: state.credits[solanaAddress],
        deviceId: deviceId
      }
    };
  }

  // Add Credits (called after Solana NFT mint)
  if (input.function === 'addCredits') {
    const { solanaAddress, amount } = input;

    // Only contract owner can add credits
    if (caller !== state.owner) {
      throw new ContractError('Unauthorized');
    }

    state.licenses[solanaAddress] = true;
    state.credits[solanaAddress] = (state.credits[solanaAddress] || 0) + amount;

    return { state };
  }

  // Get Credit Balance
  if (input.function === 'getBalance') {
    const { solanaAddress } = input;

    return {
      state,
      result: {
        hasLicense: state.licenses[solanaAddress] || false,
        credits: state.credits[solanaAddress] || 0
      }
    };
  }

  throw new ContractError('Invalid function: ' + input.function);
}

// Initial State
const initialState = {
  owner: 'arweave-wallet-address-here',
  licenses: {},  // { solanaAddress: boolean }
  credits: {},   // { solanaAddress: number }
  devices: {}    // { deviceId: { owner, activatedAt, version } }
};

🌐 ARWEAVE WEB APP DEPLOYMENT

ESP32 Flasher Tool

# 1. Build React App
cd esp32-flasher-web
npm run build
# Output: build/ folder

# 2. Deploy to Arweave
npm install -g arweave-deploy

arweave-deploy build/ \
  --key-file ~/.arweave/wallet.json \
  --index-file index.html \
  --tags \
    'App-Name:ESP32-Flasher-SolarLog' \
    'App-Version:1.0.0' \
    'Content-Type:text/html' \
    'License:Proprietary'

# Output:
# ✅ Transaction: abc123def456ghi789...
# ✅ URL: https://arweave.net/abc123def456ghi789...
# ✅ Cost: $0.005 (FOREVER!)

# 3. Register Custom Domain (ArNS)
arns register flasher-v1.solarlog.ar \
  --tx-id abc123def456ghi789... \
  --wallet ~/.arweave/wallet.json \
  --duration 1y

# Custom URL: https://flasher-v1.solarlog.ar

🔐 LICENSE VERIFICATION FLOW

User Journey: ESP32 Flash

1. User buys ESP32 Flash Credit
   ├─ Opens: https://solarlog.io/buy
   ├─ Connects Phantom Wallet
   ├─ Pays: 10 USDC
   └─ Solana Smart Contract mints NFT
       └─ NFT lands in user's wallet

2. User opens Flasher Tool
   ├─ URL: https://flasher-v1.solarlog.ar
   ├─ Loaded from Arweave (no own server!)
   └─ Web App runs in browser

3. Wallet Connection
   ├─ User clicks "Connect Wallet"
   ├─ Phantom popup appears
   ├─ User approves connection
   └─ Web App reads NFTs from wallet

4. License Verification
   ├─ Web App calls Arweave SmartWeave
   ├─ SmartWeave checks Solana NFT ownership
   ├─ Verifies ESP32 credit balance > 0
   └─ Returns: { success: true, credits: 5 }

5. Firmware Download
   ├─ Web App loads firmware from Arweave
   ├─ TX: ghi789... (ESP32_v1.0.bin)
   ├─ Direct browser download (no server!)
   └─ File: ~2 MB

6. WebSerial Flash
   ├─ User connects ESP32 via USB
   ├─ Browser → USB → ESP32
   ├─ Flashing progress: 0-100%
   └─ Success! ESP32 running

7. Credit Consumption
   ├─ Web App calls SmartWeave: useCredit()
   ├─ SmartWeave updates state: credits -= 1
   ├─ Device ID registered (MAC Address)
   └─ User sees: "4 credits remaining"

8. DONE!
   └─ ESP32 functional, license verified forever

💰 COST ANALYSIS

Blockchain Deployment Costs

Solana:
- Smart Contract Deploy: ~$50 (einmalig)
- NFT Mint: ~$0.0001 per NFT
- Transaction Fee: ~$0.00025
─────────────────────────────────
Per User Cost: ~$0.0003

Arweave:
- ESP32 Flasher v1.0 (500 KB): $0.005
- Pi Builder v1.0 (500 KB): $0.005
- SmartWeave Contract (10 KB): $0.0001
- Firmware Binary (2 MB): $0.02 per version
─────────────────────────────────
Total Deployment: ~$0.10 (einmalig!)

ArNS Custom Domains:
- flasher-v1.solarlog.ar: $50/Jahr
- builder-v1.solarlog.ar: $50/Jahr
─────────────────────────────────
Total Domains: $100/Jahr (optional)

GESAMT:
Year 1: ~$150
Year 2+: ~$100/Jahr (nur Domains)

Vergleich Traditional:
- AWS S3 + CloudFront: $600/Jahr
- Vercel Pro: $240/Jahr
- Arweave: $100/Jahr (60-80% günstiger!)

🚀 DEPLOYMENT WORKFLOW

Phase 10: Blockchain Integration (Q1 2026)

Week 1-2: Solana Smart Contract

# Setup
cargo install --git https://github.com/coral-xyz/anchor anchor-cli
solana-keygen new --outfile ~/.config/solana/deployer.json

# Develop Contract
cd solarlog-licensing-solana
anchor init solarlog_licensing
anchor build
anchor test

# Deploy to Devnet (testing)
anchor deploy --provider.cluster devnet

# Deploy to Mainnet (production)
solana airdrop 2 --url devnet  # Get SOL for fees
anchor deploy --provider.cluster mainnet-beta

# Output:
# Program ID: SoLaRLoG1i23456789aBcDeF...

Week 3-4: Arweave Web Apps

# ESP32 Flasher
cd esp32-flasher-web
npm install
npm run build
arweave-deploy build/ --key-file ~/.arweave/wallet.json

# Pi Image Builder
cd pi-builder-web
npm run build
arweave-deploy build/ --key-file ~/.arweave/wallet.json

# SmartWeave Contract
cd smartweave-licensing
arweave deploy contract.js --key-file ~/.arweave/wallet.json

Week 5: Integration & Testing

# End-to-End Test
1. Mint Test NFT (Solana Devnet)
2. Connect Wallet to Arweave App
3. Verify License (SmartWeave)
4. Download Firmware (Arweave)
5. Flash ESP32 (WebSerial)
6. Consume Credit (SmartWeave)
7. Verify Credit Deduction (Solana)

# Security Audit
1. Code Review (Internal)
2. External Audit (CertiK / Trail of Bits)
3. Bug Bounty (HackerOne)
4. Community Beta (100 testers)


🔒 SECURITY CONSIDERATIONS

1. Private Key Management

Deployer Wallet:
- Solana: ~/.config/solana/deployer.json
- Arweave: ~/.arweave/wallet.json
- Backup: Hardware Wallet (Ledger)
- Never commit to Git!

Contract Owner:
- Multi-Sig Wallet (3-of-5)
- Timelock (48h delay for critical functions)
- Emergency Pause Function

2. Smart Contract Audits

Pre-Deployment:
- Internal Code Review
- Unit Tests (100% coverage)
- Integration Tests
- Fuzzing Tests

External Audit:
- CertiK (Solana)
- Trail of Bits (Arweave)
- Cost: ~$20,000
- Duration: 2-4 weeks

Post-Deployment:
- Bug Bounty Program
- Continuous Monitoring
- Incident Response Plan

3. Arweave Gateway Redundancy

Multiple Gateways:
- https://arweave.net/TX
- https://arweave.dev/TX
- https://g8way.io/TX
- https://ar-io.net/TX
- Own Gateway (optional)

Fallback Strategy:
1. Try Primary Gateway
2. If fails → Try Secondary
3. If fails → Try Tertiary
4. If all fail → Show error + manual TX link

📈 SCALABILITY

Transaction Limits

Solana:
- TPS: 65,000 (theoretical)
- Realistic: 2,000-3,000 TPS
- Cost per TX: $0.00025
- Block Time: 400ms

Scalability for SolarLog:
- 1,000 NFT mints/day: ~$0.25/day
- 10,000 NFT mints/day: ~$2.50/day
- No scalability issues!

Arweave:
- Storage: Unlimited
- Retrieval: Gateway-limited (CDN-like)
- Cost: Fixed per MB (~$10/GB)
- No TPS limit (read-only)

🎯 ADVANTAGES SUMMARY

Feature Traditional Cloud Blockchain (Our Approach)
Availability 99.9% (server-dependent) 100% (decentralized)
Longevity Until company exists Forever (200+ years)
Censorship Possible (takedowns) Impossible
Costs $50-600/mo $0.005 + $100/yr
Lock-in High (vendor) None (portable)
Privacy Tracking possible Minimal (on-chain only)
Updates Forced Optional (versioning)
Downtime Maintenance windows None

See also: - Revenue Model - Licensing Strategy - Privacy & GDPR