Skip to content

codevskhan/Voting-Dapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 

Repository files navigation

πŸ—³οΈ Algorand Voting DApp

πŸ“Œ Project Description

This project is a Voting DApp built on Algorand using smart contracts written in TypeScript.
It provides a simple and transparent way to conduct voting on the blockchain, ensuring that votes are secure, immutable, and verifiable by anyone.

Whether you’re a beginner exploring Algorand smart contracts or a developer building decentralized applications, this project serves as a great starting point.


πŸ’‘ What it does

  • Allows users to vote for Candidate A or Candidate B.
  • Keeps track of the votes securely on the Algorand blockchain.
  • Lets anyone check the current winner at any time.

✨ Features

  • βœ… Built on Algorand blockchain (fast, secure, low fees)
  • βœ… Written in TypeScript with easy-to-read smart contract syntax
  • βœ… Immutable vote storage (cannot be changed once cast)
  • βœ… Function to retrieve the current winner
  • βœ… Beginner-friendly, simple, and extendable

πŸ”— Deployed Smart Contract

Contract Address: XXX


πŸ“ Smart Contract Code

import { Contract, GlobalState, uint64 } from "@algorandfoundation/algorand-typescript"

export class Voting extends Contract {

// Global state variables candidateA = GlobalState({ key: "candidateA", initialValue: 0 }); candidateB = GlobalState({ key: "candidateB", initialValue: 0 });

// Function to vote for Candidate A voteForA(): uint64 { this.candidateA.value = this.candidateA.value + 1; return this.candidateA.value; }

// Function to vote for Candidate B voteForB(): uint64 { this.candidateB.value = this.candidateB.value + 1; return this.candidateB.value; }

// Get current winner getWinner(): string { if (this.candidateA.value > this.candidateB.value) { return "Candidate A"; } else if (this.candidateB.value > this.candidateA.value) { return "Candidate B"; } else { return "Tie"; } } }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published