Voting, Phasing & Governance Subsystem
The Shamwari Voting, Phasing & Governance Subsystem (nxt.voting) provides a protocol-native framework for conditional transaction execution, decentralized voting, multi-signature approvals, and account-level governance enforcement built directly into the core Shamwari ledger engine.
By handling transaction phasing and voting directly within nxt.voting—rather than relying on external virtual machine smart contracts—Shamwari achieves zero-overhead condition evaluation, reentrancy-safe multi-signature workflows, composable boolean voting logic, and native integration with on-chain holdings, properties, identity credentials, and post-quantum account controls across BetaChains.
Core Capabilities & Architecture
- Protocol-Native Transaction Phasing (
PhasingAppendix): Transactions can be attached with aPhasingAppendix(appendixType = 64), deferring final execution until defined block heights or until explicit on-chain approval criteria (quorum) are satisfied. - Multi-Model Vote Weighting (
VoteWeighting): Supports 10 distinct voting models—including per-account (ACCOUNT), totem-weighted (TOTEM), currency-weighted (CURRENCY), secret pre-image revelation (HASH), property verification (PROPERTY), linked transaction dependency (TRANSACTION), demographic identity data (IDENTITY_DATA), and verified credential certificates (CERTIFICATE). - Composite Boolean Logic Expressions (
CompositeVoting): Enables complex multi-condition governance rules by evaluating boolean expressions () over multiple distinct sub-polls in real time. - Mandatory Account Control (
PhasingControl): Account-level policy enforcement that forces all outgoing transactions from an account to be phased under mandatory governance rules (e.g., -of- corporate treasury approvals or board consent). - Real-Time Early Execution & Rejection Engine: Block listeners (
tryCountVotes) evaluate pending phased transactions at every block. Transactions meeting quorum release early immediately, while transactions failing boolean logic rejections fail fast, freeing pending resources. - Atomic State Rollbacks: Unconfirmed attachment funds and reserved asset balances are safely unlocked and restored if a phased transaction is rejected or fails to meet quorum before its finish height.
Voting Models & Parameter Matrix
The core engine supports multiple voting models defined in VoteWeighting.VotingModel:
| Voting Model | Code | Weighting Source & Criterion | Primary Use Case |
|---|---|---|---|
NONE | 0 | No voting model; default baseline. | Simple time-based execution delays. |
ACCOUNT | 1 | 1 Account = 1 Vote (Equal Weighting). | Multi-sig approvals, council voting, DAO governance. |
TOTEM | 2 | Weighted by holdings of a specific Totem (holding_id). | Token-weighted shareholder voting & dApp governance. |
CURRENCY | 3 | Weighted by holdings of a Monetary System currency. | Currency-holder monetary policy referendums. |
HASH | 4 | Requires revealing a secret pre-image matching hashedSecret. | Atomic cross-chain swaps (HTLCs) & secret releases. |
PROPERTY | 5 | Requires recipient or sender to possess specified Account Property key/value. | Role-based permissioning & compliance gating. |
TRANSACTION | 6 | Execution depends on the confirmation of linked transaction IDs. | Sequential transaction pipelines & conditional cascades. |
IDENTITY_DATA | 7 | Gated by age bounds, gender, or nationality profile attributes. | Demographic voting & regional governance. |
CERTIFICATE | 8 | Gated by verified credentials issued by accredited institutions. | Academic, accredited investor, or regulatory voting. |
COMPOSITE | 9 | Boolean expression logic combining multiple sub-polls (). | Advanced corporate governance & multi-tier authorization. |
Data Model & Relational Schema
Phasing parameters, active poll structures, vote tallies, and account controls are maintained in relational database tables indexed by transaction IDs, account keys, and block heights.
1. Primary Phasing & Governance Entities
| Table | Primary / Composite Key | Entity Class | Description |
|---|---|---|---|
public.phasing_poll | id, height | PhasingPoll | Active phasing poll registrations, quorum targets, and finish heights. |
public.phasing_vote | id, voter_id | PhasingVote | Individual voter submissions and cast weight records. |
public.phasing_control | account_id, height | PhasingControl | Active account governance policies requiring mandatory transaction phasing. |
2. Phasing Parameters Schema (PhasingParams)
Phasing parameters encode the precise approval criteria required for transaction release:
| Field | SQL Type | Description |
|---|---|---|
voting_model | TINYINT | Numerical code mapping to VoteWeighting.VotingModel. |
quorum | BIGINT | Total required vote weight or threshold count to approve execution. |
holding_id | BIGINT | Totem or Currency ID used for weighted voting ( for account voting). |
min_balance | BIGINT | Minimum balance threshold required for a voter's vote to be valid. |
min_balance_model | TINYINT | Balance evaluation model (e.g., liquid balance, locked balance). |
expression | VARCHAR | Boolean algebra expression string for COMPOSITE voting models. |
sender_property_setter_id | BIGINT | Required account ID of the setter for sender property checks. |
sender_property_name | VARCHAR | Property key name required on sender account. |
sender_property_value | VARCHAR | Expected property value string on sender account. |
recipient_property_setter_id | BIGINT | Required account ID of the setter for recipient property checks. |
recipient_property_name | VARCHAR | Property key name required on recipient account. |
recipient_property_value | VARCHAR | Expected property value string on recipient account. |
nationality | VARCHAR | ISO country code filter for IDENTITY_DATA voting. |
gender | VARCHAR | Gender string filter for IDENTITY_DATA voting. |
min_age | INT | Minimum voter age constraint derived from dateOfBirth. |
max_age | INT | Maximum voter age constraint derived from dateOfBirth. |
certificate_issuer | BIGINT | Issuer account ID of required verification certificate. |
certificate_name | VARCHAR | Credential name for CERTIFICATE voting. |
certificate_type | VARCHAR | Credential category for CERTIFICATE voting. |
Transaction Phasing State Machine
A phased transaction undergoes state transitions from initial broadcast to either execution or rejection:
┌───────────────────────────────────────────────┐
│ Transaction Broadcast + PhasingAppendix │
└───────────────────────┬───────────────────────┘
│
▼
┌───────────────────────────────────────┐
│ PENDING PHASED │
│ (Held in PhasingPollHome Registry) │
└───────┬───────────────┬───────┬───────┘
│ │ │
tryCountVotes() │ │ │ tryCountVotes()
Quorum Met / Composite TRUE │ │ │ Composite FALSE
▼ │ ▼
┌───────────────┐ │ ┌───────────────────────┐
│ EARLY RELEASE │ │ │ EARLY REJECTION │
└───────┬───────┘ │ └───────────┬───────────┘
│ │ │
│ Finish Height Reached │
│ (countVotes()) │
│ │ │
▼ ▼ ▼
┌───────────────────────────────────────┐
│ FINAL STATE │
├───────────────────────┬───────────────┤
│ RELEASED (Executed) │ REJECTED │
└───────────────────────┴───────────────┘
Mathematical Formulas & Quorum Logic
1. Vote Weight Attribution
When a voter casts a vote on a phased poll, their vote weight () is determined based on the specified VotingModel: