andrewhong5297 / farpoll

boilerplate for sending frame data to the "Frame" EAS schema for easier data tracking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Farpoll

Important

Put a question "?" and options "[a,b,c]" into a cast and paste the link https://ask.farpoll.com/start. This will automagically turn it into an onchain poll frame on Farcaster.

This repo is the code behind ask.farpoll.com/start, which is a frame on Farcaster that will parse the question and button options from within a cast, and then store the vote results onchain using this EAS schema.

Additionally, the frame displays transaction confirmations with onceupon.gg and then redirects out to dune.com to showcase analytics behind the voters.

Having the vote data onchain through EAS allows for frames to essentially act as smart contracts that emit "logs". This is useful for more than just analytics, you could tie it to "reserving" a mint as well. I'm still exploring offchain options for cheaper storage.

Setup

Put in the relevant keys in the .env file. If you want to post to your own EAS schema with more variables, go create a schema and edit the encoder and schemaUID. You also have the option to change the code to post offchain if you want to, docs are linked in the script.

For testing, I recommend you localhost into an ngrok and then test with this developer frames frontend.

To start, install all the packages.

npm install

If you make edits to the poll.jsx file, remember to run npm run build to update the js file that gets actually run. Bonus points if someone figures out webpacks and how to get this to build on the fly.

To run the app locally, use:

npm run dev

To run the app in production, use:

npm start

I'm a javascript noob so ignore all my spaghetti code. Feel free to make PRs with improvements and thoughts 😁

Frame Logical Flow

This is the flow of frames that can be found in endpoints in index.js. I use an express app to manage the backend.

  1. start on /start page, ask users to click "load poll".
  2. go to /poll, and check if user has already made an attestation. If so, show them the confirmation of their attestation and push them to /results screen
  3. if not, give them the /poll screen that pulls questions/options from the cast (parses first question mark, and options out of a [a,b,c])
  4. return onceupon frame after confirmation. let them click "see results" to push them to /results screen
  5. shows them poll results screen, which has a redirect to the dune dashboard to see voter distribution data.

Example Cast

Create any onchain poll directly within a cast, show the confirmed transaction in frame, and then take them to a Dune dashboard showing data on voters.

Live now with Farpoll!

How excited are you about frames? [not excited, a little, a lot]

https://ask.farpoll.com/start

About

boilerplate for sending frame data to the "Frame" EAS schema for easier data tracking


Languages

Language:JavaScript 100.0%Language:Procfile 0.0%