Inspiration

After getting introduced to tons of tools and resources for new blockchain developers like myself in this hackathon, especially Chainlink and Moralis, I went through a bunch of tutorials and workshops to create a React Dapp that aims to answer the age-old debate: which pet is better? A cat 😼 or a dog 🐶?

The inspiration behind this was tons of discussion with friends, family and acquaintances in the past as to which pet between the two is better.

It was finally time to create a Dapp Poll powered by blockchain technology to answer this question in a non-autonomous manner, and that is exactly why I created this project.

What it does

It is a React Dapp that lets you connect your wallet and cast exactly one vote, either an up or a downvote, for the two animals. You can either choose to upvote both of them (unbiased animal lover), downvote both of them (unbiased animal hater), or up and downvote one or the other (biased animal lover), to change the preferred % ratio for the purry and barking creature respectively.

Depending on the number of votes and voters, the preferred % ratio for each of the animals is calculated, updated and displayed.

How I built it

I am very new to blockchain development so I had to go through a bunch of Chainlink and Moralis tutorials to understand how to locally build smart contracts and web apps using Solidity, hardhat, and React. I then tweaked my tutorial project knowledge to make this Dapp.

Here is a list of tools and technologies I used to build this:

  • Solidity: Write my smart contract code
  • Chainlink: Experiment with ETH/USD conversion
  • Hardhat/Rinkeby Testnet: Compile, deploy and verify my smart contracts
  • React + basic HTML/CSS: Build a single-page web app
  • Moralis: Connect smart contract and web app, sync events and live query the Votes database table
  • GitHub Pages: Host my React web app on a live server

Challenges I ran into

Too many to list, but the biggest challenge was the learning curve behind all these different components working together and trying to get the dev environment set up properly. It was my first time creating almost all the elements of this project so a lot of Googling, frustration and pep talk was necessary to get me through it.

  • I originally planned to use Polygon Mumbai but couldn't set that up so had to switch to Rinkeby.
  • My web app kept crashing if there was any RPC error due to authentication or other user interaction on the app with the smart contract, so used try/catch {} and alerts to fix it.
  • I also ran into a lot of problems trying to host the web app on GH Pages, ultimately I just pushed the build folder contents in a separate repository and generated the GH Page link that way, not the most efficient way of doing things, but at least it works!

Accomplishments that I'm proud of

I am extremely proud that I was finally able to build a project that I can submit before the deadline for this hackathon, as that was my main goal entering this hackathon and at the beginning, I had no knowledge about what and how to create anything blockchain-related.

With the project itself, I am super proud that I was able to deploy and verify my smart contract on the Rinkeby Testnet as well as create my first ever Dapp and figure out how to host it for free using GitHub Pages as I spent hours trying to figure out how to do it all on my own.

What I've learned

Literally, everything that went behind creating this project, right from creating a Metamask wallet to solidity syntax, installing and using hardhat to deploying and verifying smart contracts on Rinkeby Etherscan, creating a React app to hosting it on GH pages, and everything in between, all of it was very new to me, so I learned a ton, an unimaginable amount while working on this project but at the same time my imposter syndrome makes me feel like I have forgotten everything already and know nothing 🙃

What's next for The Ultimate Cats vs Dogs Poll

Not really sure, just encourage as many people to vote so I find the answer to the poll.

I was trying to get DOGE and MEOW coin valuation listed on the site for fun but couldn't find the right Chainlink data feed information for it, specifically for the Rinkeby Testnet.

I want to learn more about NFTs and DAOs so perhaps will use this project to test those out, otherwise, move on to creating a completely new project and further build my blockchain dev skills.

Built With

Share this project:

Updates