Welcome to the Public Opinion Poll frontend, a decentralized application built on the Aptos Blockchain. This platform enables users to create polls, participate in voting, and view results transparently and securely through blockchain-based smart contracts. Poll creators can manage participation and finalize results with seamless identity verification using DIDs (Decentralized Identifiers).
- Live Demo: Public Opinion Poll
- Smart Contract Explorer: Aptos Explorer
- Create Polls: Users can create new polls by defining a question and multiple-choice options.
- Vote on Polls: Participants can vote for options in open polls using their DIDs.
- View Poll Results: Users can view real-time poll results with individual and total vote counts.
- Close Polls: Poll creators can close polls to end voting and finalize results.
- DID Verification: Votes are linked to usersβ DIDs to prevent duplicate voting and ensure transparency.
Make sure you have the following installed:
- Node.js (v16 or higher)
- npm or yarn
- Aptos Wallet (e.g., Petra Wallet) for blockchain transactions
Clone the project and navigate to the project folder:
cd public-opinion-poll
Install the necessary dependencies:
npm install
Create a .env
file in the root directory and add:
VITE_APP_NETWORK=testnet
VITE_MODULE_ADDRESS="0x53ebd2be721663376dc5a39997d54f160bfb4195da6db5edb97fab2927e90c37"
Start the local server with:
npm run dev
The app will be available at http://localhost:5173.
To deploy the smart contract:
-
Install Aptos CLI.
-
Update the Move.toml file with your wallet address:
- Add you Wallet Address from Petra here
poll_addrx = "0xca10b0176c34f9a8315589ff977645e04497814e9753d21f7d7e7c3d83aa7b57"
-
Create your new Address for Deployment
aptos init
- Add your Account addr here for Deployment
my_addrx = "53ebd2be721663376dc5a39997d54f160bfb4195da6db5edb97fab2927e90c37"
-
Compile and publish the contract:
aptos move compile aptos move publish
- Click Connect Wallet to link your Aptos wallet (e.g., Petra Wallet).
- This allows you to create polls, cast votes, and manage your participation.
- Navigate to Create Poll.
- Provide the poll question and options.
- Submit to create the poll on the blockchain.
- Browse available polls under Active Polls.
- Select a poll and enter your vote along with your DID.
- Confirm the transaction via your wallet to cast your vote.
Users can browse the Results section to view detailed voting results, including:
- Total votes per option
- Overall participation
- Status of the poll (Open/Closed)
Poll creators can:
- Navigate to Manage Polls.
- Select a poll and click Close Poll.
- Finalize the poll, locking the results.
npm run dev
: Starts the development server.npm run build
: Builds the app for production.npm test
: Runs tests.
- React: JavaScript library for building user interfaces.
- TypeScript: Typed superset of JavaScript for enhanced development.
- Aptos SDK: For interacting with the Aptos blockchain.
- Ant Design: Elegant and responsive UI components.
- Tailwind CSS: Utility-first framework for custom styling.
- Petra Wallet Adapter: For wallet integration with Aptos.
- create_poll(account, question, options): Creates a poll on the blockchain.
- vote(did, poll_id, option_index): Records a user's vote.
- get_poll(poll_id): Retrieves poll details, including options and votes.
- get_poll_results(poll_id): Fetches the total votes for each option.
- close_poll(account, poll_id): Closes the poll to end voting.
- Smart Contracts: All poll operations are managed by blockchain-based smart contracts.
- DID Verification: Votes are linked to usersβ decentralized identifiers to ensure transparency and fairness.
- Immutable Records: All transactions and votes are permanently recorded on the blockchain.
- Wallet Connection Issues: Ensure your Aptos-compatible wallet is installed and set to the correct network (e.g., Testnet).
- RPC Rate Limits: If public RPC nodes reach their request limits, consider using private RPC nodes.
- Transaction Failures: Verify wallet permissions and ensure sufficient test tokens for gas fees.
If deploying on Vercel or other platforms, you may encounter RPC rate limits. Consider:
- Using QuickNode or Alchemy as RPC providers.
- Implementing request throttling to avoid exceeding limits.
- Switching to WebSockets for real-time updates.
The Public Opinion Poll platform offers a secure and transparent way to create, participate in, and manage polls using the power of blockchain. With a user-friendly interface and reliable identity verification through DIDs, the platform ensures fairness in voting and a seamless experience for both participants and poll creators.