The objective was to develop a dApp for the voting contract provided by Alyra. The dapp must take over the complete journey of the contract and must provide differents interfaces for several types of profiles (owner, voters, non registered user).
I added as few modifications as possible in the contract:
- add natspecs for documentation
- remove the genesis proposal to avoid side effects
- remove the modifier onlyVoters in the function getOneProposal to allow unregistered users to see the description of the proposal (as indicated in the instructions of the exercice)
- prevent a DoS service by adding a check of the number of proposals in the addProposal function
require(proposalsArray.length < 1000, "Too many proposals");
I developed my interfaces in TypeScript and I replaced the default create-react-app provided React Truffle Box by NextJs. I used TailwindCSS for the styling of my components.
I recorded a short video presenting the differents interfaces [link to the video] and deploy the dApp to Vercel [link]
I deployed the dApp on the Goerli network. Here the deployment logs:
truffle migrate --network goerli
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'goerli'
> Network id: 5
> Block gas limit: 30000000 (0x1c9c380)
1_deploy_voting.js
==================
Replacing 'Voting'
------------------
> transaction hash: 0x9e6814e47a580040965bb22868d477bf3943593da0ce3d0a27a7a4f0a2d6ecd2
> Blocks: 1 Seconds: 13
> contract address: 0x206b7a9FfaBa7B53F59B9a374ad29d87b915043f
> block number: 7998030
> block timestamp: 1669106664
> account: 0x876476aF52Bd7C2184fFf2dE4543356E4Baa56cA
> balance: 0.312871882377055147
> gas used: 1944739 (0x1daca3)
> gas price: 68.155648605 gwei
> value sent: 0 ETH
> total cost: 0.132544947912439095 ETH
Pausing for 2 confirmations...
-------------------------------
> confirmation number: 1 (block: 7998031)
> confirmation number: 2 (block: 7998032)
> Saving artifacts
-------------------------------------
> Total cost: 0.132544947912439095 ETH
Summary
=======
> Total deployments: 1
> Final cost: 0.132544947912439095 ETH
```