EchoVote is a decentralized voting system built on Bitcoin through the Stacks blockchain. It allows for the creation of proposals and secure, transparent voting, leveraging the security and longevity of the Bitcoin network.
- Create and manage proposals
- Secure voting mechanism
- Vote counting and result retrieval
- Built on Stacks blockchain, leveraging Bitcoin's security
- RESTful API for easy integration
- Robust error handling and logging
- Input validation for enhanced security
echovote/
│
├── contracts/
│ └── echovote.clar
│
├── src/
│ ├── config/
│ │ └── index.ts
│ │
│ ├── middleware/
│ │ ├── errorHandler.ts
│ │ ├── notFoundHandler.ts
│ │ └── validateRequest.ts
│ │
│ ├── routes/
│ │ ├── proposalRoutes.ts
│ │ └── voteRoutes.ts
│ │
│ ├── services/
│ │ ├── proposalService.ts
│ │ └── voteService.ts
│ │
│ ├── utils/
│ │ ├── logger.ts
│ │ └── stacksUtils.ts
│ └── index.ts
│
│
├── .env.example
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
- Node.js (v14 or later)
- npm or yarn
- Stacks account with testnet STX tokens
-
Clone the repository:
git clone https://github.com/nicholas-source/echovote.git cd echovote
-
Install dependencies:
npm install
-
Copy the example environment file and update it with your values:
cp .env.example .env
Update the .env
file with your specific configuration:
PORT=3000
NETWORK=testnet
CONTRACT_ADDRESS=your_contract_address
CONTRACT_NAME=echovote
PRIVATE_KEY=your_private_key
Make sure to replace your_contract_address
and your_private_key
with your actual Stacks contract address and private key.
-
Build the TypeScript code:
npm run build
-
Start the server:
npm start
For development with hot-reloading:
npm run dev
POST /api/proposals
: Create a new proposalGET /api/proposals/:id
: Get a proposal by IDPOST /api/votes
: Cast a voteGET /api/votes/count/:proposalId/:voteOption
: Get vote count for a specific option
For detailed API documentation, refer to the API documentation (TODO: Add link to API docs).
The EchoVote smart contract is written in Clarity and provides the following functions:
create-proposal
: Create a new proposalvote
: Cast a vote for a proposalclose-proposal
: Close a proposal (admin only)get-proposal
: Get proposal detailsget-vote-count
: Get vote count for a specific optionget-total-votes
: Get total votes for a proposal
Run the test suite:
npm test
This will run both unit and integration tests.
We welcome contributions to EchoVote! Please see our Guide for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.