A decentralized voting platform built on Stacks blockchain with Clarity 4 smart contracts and Next.js
Contract Address: SP1C5DP9C9N2MB8DMZN18EJNSSA3GYNJE3DGN806V.voting
- 📝 Create Proposals - Anyone can submit proposals with title, description, and voting period
- 🗳️ Weighted Voting - Cast votes with customizable voting weights
- ⚖️ Fair Governance - Transparent, on-chain voting mechanism
- ⏰ Time-based Voting - Proposals have defined start and end blocks
- 🔒 Immutable Results - All votes permanently recorded on blockchain
- ✅ Proposal Execution - Execute passed proposals after voting ends
- 🎨 Modern, glassmorphic UI design
- 🔐 Seamless wallet integration (Hiro/Leather)
- 📱 Fully responsive mobile-first design
- ⚡ Real-time proposal updates
- 🌈 Beautiful gradient animations
- 🔄 Automatic vote counting and progress tracking
- Node.js 18+
- npm or yarn
- Hiro Wallet or Leather Wallet
- Clarinet (for deployment)
-
Clone the repository
git clone https://github.com/LFGBanditLabs/stacksvote.git cd stacksvote -
Install frontend dependencies
cd voting-frontend npm install -
Start development server
npm run dev -
Open your browser
http://localhost:3000
stacksvote/
├── counter/ # Clarity smart contract project
│ ├── contracts/
│ │ └── voting.clar # Main voting contract
│ ├── tests/
│ │ └── voting.test.ts # Contract tests
│ ├── settings/
│ │ └── Mainnet.toml # Deployment configuration
│ └── Clarinet.toml # Clarinet project config
│
└── voting-frontend/ # Next.js frontend application
├── app/
│ ├── page.tsx # Homepage
│ ├── create/
│ │ └── page.tsx # Create proposal page
│ └── layout.tsx # Root layout
├── components/
│ ├── Header.tsx # Navigation header
│ ├── ProposalCard.tsx # Proposal display component
│ └── ProposalList.tsx # Proposal listing
├── contexts/
│ └── AuthContext.tsx # Wallet authentication
├── lib/
│ ├── stacks.ts # Blockchain interactions
│ └── constants.ts # App configuration
└── package.json
(create-proposal (title (string-utf8 256))
(description (string-utf8 1024))
(duration uint))
Create a new proposal with voting duration in blocks (~10 minutes per 100 blocks).
(cast-vote (proposal-id uint) (vote-choice bool))
Vote on a proposal. true = Yes, false = No. Uses voter's weight.
(set-voter-weight (voter principal) (weight uint))
Set voting weight for a user (owner only). Default weight is 1.
(execute-proposal (proposal-id uint))
Mark proposal as executed after voting period ends.
get-proposal(proposal-id)- Retrieve proposal detailsget-proposal-count()- Total number of proposalsis-proposal-active(proposal-id)- Check if voting is activeget-proposal-result(proposal-id)- Get voting resultsget-voter-weight(voter)- Get user's voting weightget-vote(proposal-id, voter)- Get specific vote details
-
Configure deployment
cd counter cp settings/Mainnet.toml.example settings/Mainnet.toml # Add your mnemonic to Mainnet.toml -
Generate deployment plan
clarinet deployments generate --mainnet -
Deploy to mainnet
clarinet deployments apply --mainnet
Or manually:
cd voting-frontend
npm run build
npm start
cd counter
npm test
cd voting-frontend
npm run dev
- Connect your Stacks wallet
- Click "Create New Proposal"
- Fill in:
- Title: Short proposal name
- Description: Detailed explanation
- Duration: Voting period (in blocks)
- Submit and confirm transaction
- Browse active proposals on homepage
- Click "Vote Yes" or "Vote No"
- Confirm transaction in wallet
- Vote is recorded on-chain
- Progress bars show current vote distribution
- Total votes displayed for each option
- Proposal status indicates if voting is active
Edit voting-frontend/lib/constants.ts:
export const CONTRACT_ADDRESS = 'YOUR_CONTRACT_ADDRESS';
export const CONTRACT_NAME = 'voting';
export const NETWORK = 'mainnet'; // or 'testnet'
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Stacks
- Frontend powered by Next.js
- Smart contracts in Clarity
- UI styled with Tailwind CSS
- Wallet integration via @stacks/connect
- GitHub Issues: Report bugs or request features
- Stacks Discord: Join the community
Made with ❤️ by LFGBanditLabs
⭐ Star this repo if you find it useful!