🎯 Three Levels of Smart Contracts

LevelSmart ContractPurpose
  I Entire platformVotingFactoryVersion management, templates, licensing
 II CommunityCommunityRegistryMembership, roles, deposits, settings
III Individual pollPoll (created by factory)Specific poll logic, votes, results

Why: security, flexibility, efficiency.


🧱 Detailed Architecture

1. Platform Smart Contract (VotingFactory)



VotingFactory (platform)
    │
    ├── template_community_v1 (bytecode)
    │
    ├── template_poll_v1 (bytecode)
    │
    └── deployed_communities: [CommunityRegistry_1, CommunityRegistry_2, ...]
    

2. Community Smart Contract (CommunityRegistry)

A separate smart contract for each Community. Contains:



CommunityRegistry (party "United")
    │
    ├── members: { wallet_A: "member", wallet_B: "operator", ... }
    │
    ├── deposit_balance: 500 EUR
    │
    ├── polls: [Poll_1, Poll_2, Poll_3]
    │
    └── settings: { delegation_enabled: true, max_delegation_level: 2, quorum: 50% }
        

3. Poll Smart Contract (Poll)

Each poll is a separate smart contract

CriteriaAdvantage of this approach
SecurityHigh (error in one poll does not affect others)
Ability to delete a pollEasy (by operator)
Transparency (explorer)Each poll has its own identifier → easy to filter
ScalabilityUnlimited
AuditEach poll can be verified independently

🧩 Final Architecture Diagram



VotingFactory (platform)  (smart contract level I)
    │
   ...
    │
    │ createCommunity(parameters)
    │
    â–¼
    CommunityRegistry (party "United") (smart contract level II)
           │
          ...
           │
           │ createPoll(type: "simple", question: "...", options: [...])
           │
           â–¼
           Poll_1  (smart contract level III)
              │
              └── votes: { wallet_A: option_1, wallet_B: option_2 }
          ...
           │
           │ createPoll(type: "delegation", question: "...")
           │
           â–¼
           Poll_2 (smart contract level III)
              │
              ├── votes: ...
              │
              └── delegations: { wallet_C: wallet_A, wallet_D: wallet_A }