Skip to content

VESTAr-BAY/vestar-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VESTAr logo

VESTAr app icon

VESTAr Contracts

Smart contracts for VESTAr's organizer gating, clone-based election deployment, open/private voting, and paid settlement on Status Network.

Frontend Β· Backend Β· Demo Video Β· Project Description

Related Repositories

Repository How it connects to this contracts repo
vestar-contracts Core onchain runtime for election creation, voting, reveal, and settlement
vestar-frontend Host flows, voting UI, and verification portal built on top of these contracts
vestar-backend Indexed read APIs, private vote preparation, and automated key reveal workers

Overview

English
This repository contains the onchain core of VESTAr. It is responsible for deciding who can create elections, how votes are accepted, how private voting is revealed, and how paid voting revenue is settled. The design is modular, but the top-level experience is simple: registries gate creation, the factory deploys election clones, and each election handles its own lifecycle.

ν•œκ΅­μ–΄
이 μ €μž₯μ†ŒλŠ” VESTAr의 온체인 핡심 λ‘œμ§μ„ λ‹΄κ³  μžˆμŠ΅λ‹ˆλ‹€. λˆ„κ°€ νˆ¬ν‘œλ₯Ό 생성할 수 μžˆλŠ”μ§€, νˆ¬ν‘œκ°€ μ–΄λ–€ λ°©μ‹μœΌλ‘œ μ œμΆœλ˜λŠ”μ§€, λΉ„κ³΅κ°œ νˆ¬ν‘œκ°€ μ–Έμ œ κ³΅κ°œλ˜λŠ”μ§€, 유료 νˆ¬ν‘œ 수읡이 μ–΄λ–»κ²Œ μ •μ‚°λ˜λŠ”μ§€λ₯Ό 이 μ €μž₯μ†Œκ°€ κ²°μ •ν•©λ‹ˆλ‹€. κ΅¬μ‘°λŠ” λͺ¨λ“ˆν˜•μ΄μ§€λ§Œ 흐름은 λ‹¨μˆœν•©λ‹ˆλ‹€. λ ˆμ§€μŠ€νŠΈλ¦¬κ°€ 생성 μžκ²©μ„ νŒλ‹¨ν•˜κ³ , νŒ©ν† λ¦¬κ°€ election clone을 λ°°ν¬ν•˜λ©°, 각 election μΈμŠ€ν„΄μŠ€κ°€ μžμ‹ μ˜ 생λͺ…μ£ΌκΈ°λ₯Ό 직접 κ΄€λ¦¬ν•˜λŠ” λ°©μ‹μž…λ‹ˆλ‹€.

Key Features

English

  • Organizer verification and creation gating through onchain registries.
  • Clone-based election deployment for consistent runtime behavior.
  • Support for both open voting and private encrypted voting.
  • Commitment-verified private key reveal for verifiable private results.
  • Paid voting settlement with an ERC20-based revenue split.

ν•œκ΅­μ–΄

  • 온체인 λ ˆμ§€μŠ€νŠΈλ¦¬λ₯Ό ν†΅ν•œ 주졜자 검증과 생성 자격 관리 κ΅¬μ‘°μž…λ‹ˆλ‹€.
  • μΌκ΄€λœ λ™μž‘μ„ μœ„ν•œ clone 기반 election 배포 κ΅¬μ‘°μž…λ‹ˆλ‹€.
  • 곡개 νˆ¬ν‘œμ™€ λΉ„κ³΅κ°œ μ•”ν˜Έν™” νˆ¬ν‘œλ₯Ό λͺ¨λ‘ μ§€μ›ν•©λ‹ˆλ‹€.
  • λΉ„κ³΅κ°œ κ²°κ³Ό 검증을 μœ„ν•œ commitment-verified key reveal κ΅¬μ‘°μž…λ‹ˆλ‹€.
  • ERC20 기반 수읡 λΆ„λ°°λ₯Ό ν¬ν•¨ν•œ 유료 νˆ¬ν‘œ μ •μ‚° κ΅¬μ‘°μž…λ‹ˆλ‹€.

Visibility modes Ballot policies Payment modes

Architecture

English
At a high level, VESTAr contracts are organized around three layers: registries, factory, and election instances. Registries provide organizer and karma context, the factory enforces creation rules and deploys clones, and each deployed election handles voting, reveal, finalization, and settlement.

ν•œκ΅­μ–΄
큰 νλ¦„μ—μ„œ VESTAr μ»¨νŠΈλž™νŠΈλŠ” λ ˆμ§€μŠ€νŠΈλ¦¬, νŒ©ν† λ¦¬, election μΈμŠ€ν„΄μŠ€μ˜ μ„Έ 측으둜 κ΅¬μ„±λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. λ ˆμ§€μŠ€νŠΈλ¦¬λŠ” μ£Όμ΅œμžμ™€ μΉ΄λ₯΄λ§ˆ 정보λ₯Ό μ œκ³΅ν•˜κ³ , νŒ©ν† λ¦¬λŠ” 생성 κ·œμΉ™μ„ κ²€μ¦ν•œ λ’€ clone을 λ°°ν¬ν•˜λ©°, μ‹€μ œ election μΈμŠ€ν„΄μŠ€λŠ” νˆ¬ν‘œ, 곡개, μ΅œμ’… ν™•μ •, 정산을 λ‹΄λ‹Ήν•©λ‹ˆλ‹€.

flowchart LR
  Admin[Admin / Organizer] --> OrgReg[OrganizerRegistry]
  Status[Status Karma] --> KarmaReg[KarmaRegistry]
  OrgReg --> Factory[ElectionFactory]
  KarmaReg --> Factory
  Factory --> Election[VESTArElection clone]
  Voter[Voter] --> Election
  Worker[Backend worker / indexer] --> Election
  Token[MockUSDT / ERC20] --> Election
Loading

VESTAr contracts architecture

Contract Suite

Contract Role
VESTArOrganizerRegistry Stores organizer profile data and verification state
VESTArKarmaRegistry Reads Status Karma and KarmaTiers for eligibility checks
VESTArElectionFactory Validates organizer eligibility and deploys election clones
VESTArElection Per-election runtime covering lifecycle, voting, reveal, and settlement
MockUSDT 6-decimal ERC20 used for paid vote flows on testnet

English
If you want implementation-level detail, the internal contract map is documented in src/vestar/README.md.

ν•œκ΅­μ–΄
κ΅¬ν˜„ λ‹¨μœ„μ˜ 더 μžμ„Έν•œ ꡬ쑰가 ν•„μš”ν•˜λ©΄ src/vestar/README.mdμ—μ„œ λ‚΄λΆ€ 폴더와 λͺ¨λ“ˆ ꡬ성을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

Election Lifecycle

English
Open and private elections share the same broad lifecycle, but private elections add a reveal step before finalization. That reveal step is what allows temporary privacy during voting and verifiability afterward.

ν•œκ΅­μ–΄
곡개 νˆ¬ν‘œμ™€ λΉ„κ³΅κ°œ νˆ¬ν‘œλŠ” 큰 생λͺ…μ£ΌκΈ°λ₯Ό κ³΅μœ ν•˜μ§€λ§Œ, λΉ„κ³΅κ°œ νˆ¬ν‘œλŠ” μ΅œμ’… ν™•μ • 전에 key reveal 단계가 ν•œ 번 더 λ“€μ–΄κ°‘λ‹ˆλ‹€. 이 단계 덕뢄에 μ§„ν–‰ μ€‘μ—λŠ” ν”„λΌμ΄λ²„μ‹œλ₯Ό μœ μ§€ν•˜κ³ , μ’…λ£Œ ν›„μ—λŠ” κ²°κ³Όλ₯Ό λ‹€μ‹œ 검증할 수 μžˆμŠ΅λ‹ˆλ‹€.

flowchart LR
  Scheduled --> Active --> Closed
  Closed --> Finalized
  Closed --> KeyRevealPending
  KeyRevealPending --> KeyRevealed --> Finalized
  Finalized --> Settled
Loading

On-Chain Rules

English

  • startAt < endAt and resultRevealAt >= endAt are validated onchain.
  • FREE elections require zero cost, while PAID elections require a token and a positive price.
  • PRIVATE elections require a public key, a commitment hash, and keySchemeVersion == 1.
  • ONE_PER_INTERVAL requires a positive reset interval.
  • UNLIMITED_PAID is single-choice only and currently enforces costPerBallot == 66_000.
  • finalizeResults(...) requires the correct terminal state before execution.

ν•œκ΅­μ–΄

  • startAt < endAt, resultRevealAt >= endAt κ·œμΉ™μ„ μ˜¨μ²΄μΈμ—μ„œ κ²€μ¦ν•©λ‹ˆλ‹€.
  • FREE election은 λΉ„μš©μ΄ 0이어야 ν•˜κ³ , PAID election은 토큰 μ£Όμ†Œμ™€ μ–‘μˆ˜ 가격이 ν•„μš”ν•©λ‹ˆλ‹€.
  • PRIVATE election은 κ³΅κ°œν‚€, 컀밋 ν•΄μ‹œ, keySchemeVersion == 1 쑰건이 ν•„μš”ν•©λ‹ˆλ‹€.
  • ONE_PER_INTERVAL은 μ–‘μˆ˜ reset interval이 ν•„μš”ν•©λ‹ˆλ‹€.
  • UNLIMITED_PAIDλŠ” 단일 μ„ νƒλ§Œ ν—ˆμš©ν•˜λ©° ν˜„μž¬ costPerBallot == 66_000을 κ°•μ œν•©λ‹ˆλ‹€.
  • finalizeResults(...)λŠ” μ˜¬λ°”λ₯Έ μ’…λ£Œ μƒνƒœμ— λ„λ‹¬ν•œ λ’€μ—λ§Œ μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Repository Layout

contracts/
β”œβ”€ abi/                    # ABI handoff artifacts and deployment address snapshots
β”œβ”€ script/                 # Foundry deployment and sync scripts
β”œβ”€ src/
β”‚  β”œβ”€ config/              # Network-specific constants
β”‚  β”œβ”€ interfaces/          # Public interfaces
β”‚  β”œβ”€ mocks/               # MockUSDT and test helpers
β”‚  └─ vestar/              # Registries, factory, and election runtime
β”œβ”€ test/                   # Foundry test suite
└─ foundry.toml

Quick Start

Build

forge build

Test

forge test

Deploy the Full Stack

forge script script/DeployVESTArStack.s.sol:DeployVESTArStackScript \
  --rpc-url status_hoodi \
  --broadcast \
  --gas-price 0 \
  --priority-gas-price 0

Deploy MockUSDT Only

forge script script/DeployMockUSDT.s.sol:DeployMockUSDTScript \
  --rpc-url status_hoodi \
  --broadcast \
  --gas-price 0 \
  --priority-gas-price 0

Refresh ABI Artifacts

./script/SyncStatusArtifacts.sh

Network Defaults

Item Value
Network Status Network Hoodi Testnet
Chain ID 374
RPC https://public.hoodi.rpc.status.network
EVM Version paris
Solidity 0.8.24
Status Karma 0x0700be6f329cc48c38144f71c898b72795db6c1b
Status KarmaTiers 0xb8039632e089dcefa6bbb1590948926b2463b691
Multicall3 0xcA11bde05977b3631167028862bE2a173976CA11

Development Notes

English
The current Foundry profile uses Solidity 0.8.24, evm_version = "paris", and optimizer settings tuned for deployment size. This matters because the assembled election runtime can become large without those defaults.

ν•œκ΅­μ–΄
ν˜„μž¬ Foundry 섀정은 Solidity 0.8.24, evm_version = "paris", optimizer ν™œμ„±ν™”λ₯Ό κΈ°μ€€μœΌλ‘œ 맞좰져 μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” election λŸ°νƒ€μž„μ΄ μ—¬λŸ¬ κΈ°λŠ₯을 μ‘°ν•©ν•˜λŠ” ꡬ쑰이기 λ•Œλ¬Έμ—, 이 기본값이 λ§žμ§€ μ•ŠμœΌλ©΄ 배포 크기 μ œν•œμ— 걸릴 수 있기 λ•Œλ¬Έμž…λ‹ˆλ‹€.

Notice

English
If gasless deployment is temporarily unavailable on Status Hoodi, deployment may require explicit gas settings instead of the expected zero-gas flow.

ν•œκ΅­μ–΄
Status Hoodiμ—μ„œ κ°€μŠ€λ¦¬μŠ€ 배포가 μΌμ‹œμ μœΌλ‘œ λ™μž‘ν•˜μ§€ μ•ŠλŠ” κ²½μš°μ—λŠ”, κΈ°λŒ€ν–ˆλ˜ zero-gas 흐름 λŒ€μ‹  λͺ…μ‹œμ μΈ gas μ„€μ •μœΌλ‘œ 배포해야 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors