Skip to content
On this page

Weight modes

A poll's weight_mode determines how each ballot gets weighted in the final tally. Three modes ship as canonical. Any other mode is an extension, added through the protocol's weight-mode registry (SPEC §11) without a version bump; a client that does not support a poll's mode rejects it with E_UNSUPPORTED_MODE.

All three start from the same set: a voter's qualifying UTXOs are the coins the voter's address held at the snapshot block that were at least min_days old then. Age is floor((snapshot - confirmed_height) × 10 / 1440) days, ten minutes a block. A voter whose qualifying UTXOs add up to less than min_sats weighs zero in every mode.

Code
qualifying(voter) = [ u for u in utxos_at(voter, snapshot) if age_days(u) >= min_days ]
S(voter)          = sum(u.value for u in qualifying(voter))

one_per_addressLink to this section

One address, one vote, for every address over the bar.

Code
weight(voter) = 1 if S(voter) >= min_sats else 0

Use when holdings are a membership test, not a weight: "community name change vote" where a whale should count once. min_sats and min_days set the bar. No weight_params.

satsLink to this section

One satoshi, one vote.

Code
weight(voter) = S(voter) if S(voter) >= min_sats else 0

min_sats is a floor on the voter's total, not on each coin: many small coins that are each old enough add up. min_days applies per coin.

Use when capital commitment is the signal and time does not matter. Sats-weighted polls are plutocratic by construction. No weight_params.

sats_daysLink to this section

Sats × days, with each coin's days capped.

Code
weight(voter) = sum(u.value × min(age_days(u), cap_days) for u in qualifying(voter))
                if S(voter) >= min_sats else 0

weight_params MUST be { "cap_days": <positive integer> }. The cap stops one ancient coin from drowning out every fresh commitment. There is no cap on sats.

Use when time and capital should both matter: it rewards long-term holders over short-term holders of the same capital, and a bag bought the day before the snapshot counts for nothing until it is min_days old.

Choosing per pollLink to this section

The weight_mode is declared in the poll itself (signed by the poll creator). It can't be changed after creation — the poll ID is content-addressed, so editing it produces a different poll.

Poll creation:

TypeScript
import type { Poll } from '@orangecheck/vote-core';

import { pollId } from '@orangecheck/vote-core';

declare function walletSignBIP322(message: string): Promise<string>; // your wallet's BIP-322 signer

const iso = (ms: number) =>
    new Date(ms).toISOString().replace(/\.\d{3}Z$/, 'Z');
const creator = 'bc1qcreator...';

const poll: Poll = {
    v: 0,
    kind: 'oc-vote/poll',
    creator,
    question: 'Rename the default theme?',
    options: [
        { id: 'keep', label: 'Keep current' },
        { id: 'midnight', label: 'Call it Midnight' },
    ],
    deadline: iso(Date.now() + 14 * 86_400_000), // MUST be in the future when published
    snapshot_block: 'deadline', // or a block height
    weight_mode: 'sats_days',
    weight_params: { cap_days: 180 },
    min_sats: 100_000,
    min_days: 30,
    mode: 'public',
    reveal_pk: null,
    tiebreak: 'latest',
    notes: null,
    created_at: iso(Date.now()),
    sig: { alg: 'bip322', pubkey: creator, value: '' },
};

const id = pollId(poll); // sha256 of the canonical poll with sig.value = ""
poll.sig.value = await walletSignBIP322(id); // your wallet signs the 64-hex id

Example tallyLink to this section

sats_days with cap_days = 180, min_sats = 100_000, min_days = 30, four voters:

VoterUTXOs at snapshotWeightVotes
Alice500,000 sats, 60 days old500,000 × 60 = 30,000,000midnight
Bob1,000,000 sats, 400 days1,000,000 × 180 = 180,000,000 (days capped)keep
Carol80,000 sats, 300 days0 — 80,000 is under min_satsmidnight
Dave200,000 sats, 10 days0 — under min_days, so nothing qualifieskeep

tally() returns:

JSON
{
    "state": "tallied",
    "basis": "anchored",
    "close_height": 900000,
    "snapshot_block": 900000,
    "turnout": { "voters": 2, "weight": 210000000 },
    "tallies": { "keep": 180000000, "midnight": 30000000 },
    "counted": ["<four ballot ids, ascending>"]
}

The same ballots weigh keep 1,000,000 / midnight 500,000 under sats and 1 / 1 under one_per_address. turnout counts only voters whose weight is above zero; counted lists all four voters' ballots, Carol's and Dave's included. The result names no winner: reading the tallies is the caller's policy. basis and close_height are explained in tally algorithm.

See alsoLink to this section