Scrutinx : Gasless Voting with Meta Transactions & Relayer
Overview
In Scrutinx Vote Polygon, we implemented a *gasless voting mechanism using *meta transactions and a relayer. This enables users to vote on the blockchain without directly paying gas fees, significantly improving **accessibility, **transparency, and **user experience.
Meta Transactions
What Are Meta Transactions?
Meta transactions allow users to interact with the blockchain without directly paying gas fees. A third-party service, called a relayer, pays the gas on the user’s behalf.
How Meta Transactions Work
- User Signs a Message: The user signs a message (like their vote) using their wallet (e.g., MetaMask). This message proves their intent.
- Relayer Submits the Transaction: The relayer receives the signed message, constructs the transaction, and submits it while paying the gas fee.
- Smart Contract Verifies: The smart contract verifies the signature and executes the vote if valid.
Relayer
Role of the Relayer
The relayer is a backend service that:
- Accepts signed messages from users.
- Verifies signature authenticity.
- Constructs and submits the actual blockchain transaction.
- Pays for the transaction's gas.
Relayer Implementation in Scrutinx
- Listens for incoming signed vote messages from the frontend.
- Validates signatures.
- Builds the transaction using the vote data.
- Submits the transaction to the Polygon network.
Gasless Voting
Benefits
- Accessibility: No crypto? No problem—users without MATIC can still vote.
- Improved UX: Removes gas fee complexity for non-technical users.
- Inclusivity: Encourages broader democratic participation.
How We Implemented It
- Frontend: Captures the vote and signs the data via wallet.
- API Communication: Sends signed message to relayer via REST API.
- Blockchain Execution: Relayer processes and submits the transaction to Polygon.
- User Feedback: Once confirmed, the frontend shows a success message to the user.
Challenges and Considerations
- Security: Ensuring only authorized votes are submitted and preventing misuse of the relayer.
- Scalability: Handling thousands of vote submissions under heavy load.
- Cost Management: Strategizing how to sustainably fund relayer gas payments.
Scrutinx : Hackathon Project Story
Inspiration
We were driven by the challenges in traditional voting—fraud, lack of transparency, and accessibility. Scrutinx was envisioned as a platform to make digital democracy real, powered by blockchain.
What We Learned
- Blockchain Fundamentals: Transparent and tamper-proof systems.
- Smart Contracts: Writing and deploying election logic on **Polygon using Solidity.
- *Frontend Integration: Connecting smart contracts with *web3.js and ethers.js.
- UX for Web3: Making blockchain easy for non-crypto users.
How We Built It
- Ideation: Voter registration, secure voting, result tracking, and audit logs.
- Smart Contracts: Created and deployed on **Polygon manniet.
- Frontend: Built in **React with wallet login and voting UI.
- Backend: Lightweight APIs for off-chain processes and alerts.
- Testing: Continuous user testing and contract audits ensured reliability.
Challenges We Faced
- Smart Contract Security: Required careful planning and testing.
- Gas Optimization: Reduced transaction costs by refining logic.
- User Onboarding: Made wallet interactions beginner-friendly.
- Time Constraints: Rapid MVP development during hackathon deadlines.
javascript // Simple pseudocode of the voting flow userSignsMessage(voteData); relayerReceives(message); relayerSubmitsToBlockchain(); smartContractVerifiesAndRecordsVote(); frontendShowsConfirmation();
Conclusion
Scrutinx Vote Polygon stands as a proof of concept that secure, gasless, and inclusive voting can be achieved using blockchain. We hope it sparks future innovation in the digital voting space.
Built With
- alchemy-sdk
- eslint
- ethers.js
- express.js
- firebase
- node.js
- polygon-blockchain
- postcss
- react
- react-hook-form
- react-query
- react-router
- shadcn-ui
- solidity
- tailwind-css
- typescript
- vite
- zod
Log in or sign up for Devpost to join the conversation.