Skip to content

gonkalabs/prevote

Repository files navigation

Gonka Governance Portal

A community pre-vote portal for the Gonka network.

See it in action

Gonka Governance Portal demo

Click the preview to watch the demo, or go to https://gonkavote.com to test it yourself.

People can draft proposals, discuss them, pledge support, rate them, and run a pre-vote before taking anything to chain governance. The consensus-relevant state lives in CosmWasm contracts: drafts, pledges, ratings, votes, and voting power. The backend is only an indexer and a home for off-chain UX features such as comments.

After a proposal finishes voting on the platform, the proposer can start a real cosmos.gov.v1 on-chain proposal with inferenced. The portal does not auto-submit to governance yet; it gives the community result, vote record, transaction history, and a stable page to link from the real proposal.

Architecture

apps/portal (Nuxt 3)
  - Keplr / GG Wallet
  - Feed, draft editor, pledge UI, vote UI
  - Reads fast data from the indexer
  - Sends signed transactions to Gonka

apps/indexer (NestJS)
  - Postgres projection
  - Comments and reactions
  - SIWE-style auth
  - Periodic chain sync

Gonka chain (CosmWasm)
  - dao-voting-gonka
  - dao-pre-propose-gonka
  - manual cosmos.gov.v1 handoff after pre-vote

packages/sdk
  - typed contract clients
  - Gonka RPC wrapper

What is already built

  1. CosmWasm pre-vote layer - a separate community voting layer before cosmos.gov.v1.
  2. dao-voting-gonka - voting power from locked GNK, with longer locks carrying more weight.
  3. dao-pre-propose-gonka - drafts, pledges, ratings, votes, and lifecycle state in one contract.
  4. On-chain proposal content - title, summary, body, and links are stored in contract storage with byte caps. No IPFS.
  5. DAO config in the UI - min_pledge_for_pre_vote, min_rating_voting_power, max_discussion_seconds, and admin are read from the contract and shown above the feed.
  6. Nuxt portal - feed, create proposal flow, proposal detail page, comments, activity feed, staking page, profiles, and a "How it works" page.
  7. Wallet support - Keplr and GG Wallet.
  8. On-chain actions from the UI - submit draft, pledge, rate up/down, vote yes/no, advance, cancel, finalize, lock GNK, and unlock GNK.
  9. CLI commands for every important action - each action can show the matching inferenced command, so users can verify or repeat the action outside the web app.
  10. Off-chain discussion - Reddit-style threaded comments and comment reactions live in Postgres.
  11. Indexer API - NestJS + Prisma + Postgres projection for fast reads, profiles, comments, and activity history.
  12. RPC failover - frontend and indexer can try multiple Gonka nodes.
  13. Production deployment - Docker Compose stack with postgres, indexer, portal, and caddy on gonkavote.com.

On-chain vs off-chain

On-chain, verifiable

  • Drafts - title, summary/body, links, author, and status.
  • Pledges - per-address GNK pledges.
  • Ratings - weighted up/down rating at draft level.
  • Voting power - locked GNK with duration multipliers.
  • Pre-votes - yes / no / abstain votes.
  • Lifecycle - Discussion -> PreVoting -> Finalized or canceled.

Off-chain, convenience only

  • Comments - threaded discussion and replies.
  • Comment reactions - like / dislike state.
  • Profiles - display data derived from indexed activity.
  • Search and fast reads - indexer projection of contract state.

Layout

contracts/                     # Rust / CosmWasm workspace
  packages/
    gonka-shared/              # Shared types, errors
    dao-voting-gonka/          # Custom voting module (locked GNK)
    dao-pre-propose-gonka/     # Custom pre-propose module
apps/
  indexer/                     # NestJS + Prisma + Postgres
  portal/                      # Nuxt 3 + Tailwind + Keplr / GG Wallet
packages/
  sdk/                         # TypeScript SDK (contract types + RPC client)
docs/                          # Spec, ADRs
schemas/                       # Generated JSON schemas (committed for diff)
scripts/                       # Deployment / dev helpers
docker-compose.yml             # Local Postgres

Quick start

# 0. activate Node + pnpm (one-time per shell)
source ~/.nvm/nvm.sh && nvm use --lts

# 1. install JS deps + build the SDK (other apps depend on it via workspace:*)
pnpm install
pnpm --filter @gonka/sdk build

# 2. start local Postgres
docker compose up -d postgres

# 3. apply DB schema and start indexer (port 4000, swagger at /docs)
cp apps/indexer/.env.example apps/indexer/.env
pnpm --filter @gonka/indexer db:push
pnpm --filter @gonka/indexer dev

# 4. start portal (port 3000)
pnpm --filter @gonka/portal dev

# 5. build & test contracts
cd contracts && cargo build && cargo test

Starting a real on-chain proposal after pre-vote

The portal is a pre-vote system. Once the platform vote is completed, the proposer can use the result as the public signal and start a real Gonka governance proposal through cosmos.gov.v1.

Recommended flow:

  1. Open the finalized proposal page on gonkavote.com.
  2. Check the final tally, pledges, and activity feed.
  3. Copy the portal URL and relevant transaction hashes.
  4. Prepare a proposal.json for chain governance. Put the portal URL in metadata or in the summary so validators can review the discussion and pre-vote result.
  5. Submit the proposal with inferenced tx gov submit-proposal.

Example proposal.json shape:

{
  "messages": [
    {
      "@type": "/cosmos.params.v1beta1.MsgUpdateParams",
      "authority": "<gov-module-authority>",
      "subspace": "<module>",
      "key": "<param>",
      "value": "<value>"
    }
  ],
  "metadata": "https://gonkavote.com/proposals/<id>",
  "deposit": "100000000000ngonka",
  "title": "<proposal title>",
  "summary": "This proposal passed community pre-vote on Gonka Governance Portal: https://gonkavote.com/proposals/<id>"
}

Submit it:

inferenced tx gov submit-proposal proposal.json \
  --from <your-key> \
  --keyring-backend file \
  --chain-id gonka-mainnet \
  --gas auto \
  --gas-adjustment 1.3 \
  --node https://gonka.gg/chain-rpc/ \
  -y

Notes:

  • The messages array must contain the real governance message for the change you want. The example above is only a template.
  • deposit must satisfy the current chain governance minimum deposit.
  • The portal does not submit this transaction automatically yet. The proposer keeps control of the final governance submission.

One-shot sanity check

pnpm -r typecheck     # SDK + indexer + portal all clean
pnpm -r build         # full build of all JS workspaces
cd contracts && cargo check --workspace && cargo test

Network

Mainnet RPC: https://rpc.gonka.gg (managed; provide X-Api-Key). Chain ID: gonka-mainnet. SDK ~0.50, CometBFT 0.38, wasmd 0.5x - fully DAO DAO v2 compatible.

Future work

  1. Automatic governance handoff - after a successful platform pre-vote, build a guarded flow that prepares and submits the cosmos.gov.v1 proposal from the portal.
  2. Pledge rules - add optional slashing or lock rules for abusive cancellations or spam.
  3. More voting models - quadratic voting, conviction voting, or separate rules for different proposal types.
  4. Delegation - let users lock GNK but delegate pre-vote power to another address.
  5. Contract migrations - add explicit MigrateMsg versioning and migration smoke tests before every contract upgrade.
  6. Better contract events - emit richer events for every state change so the indexer can sync with less polling.
  7. Notifications - Discord, Telegram, email, or web push for new proposals and vote deadlines.
  8. Search and filters - full-text search over proposals and comments, plus categories and tags.
  9. Analytics - charts for turnout, voting power, pledges over time, and voter activity.
  10. Audit and hardening - formal review of fund-holding contracts before adding automatic governance handoff.

License

Apache-2.0

About

Opensource pre-voting layer for gonka.ai proposals

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors