clauswilke / farcaster-followers-frame

A simple frame that displays a follower graph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

farcaster-followers-frame

Try it in warpcast

How does it work?

  • user clicks on the get my data button
  • the app receives a POST to /followers with the fid of the user
  • we hit the gRPC API of a Farcaster hub and makes a LinksByTargetRequest with the user's fid
  • we receive a list of messages and increment the follower count for every MESSAGE_TYPE_LINK_ADD and decrement it for every MESSAGE_TYPE_LINK_REMOVE
  • we create a pandas.Series object using the timestamp of the messages and the follower count
  • we plot the series using seaborn/matplotlib
  • we render the graph as a png and return it

GRPC API

# separately check out hub-monorepo
git clone https://github.com/farcasterxyz/hub-monorepo path/to/hub-monorepo

# copy the updated protobufs in our repo
cp -R path/to/hub-monorepo/protobufs farcaster-followers-frame/protobufs

# generate the client code
python -m grpc_tools.protoc -I./protobufs/schemas/ \
  --python_out=./src/fff/grpc --grpc_python_out=./src/fff/grpc protobufs/schemas/*.proto

# fix the darn imports generated by protoc
rye run protol --in-place --python-out src/fff/grpc protoc --proto-path=protobufs/schemas protobufs/schemas/*.proto

To configure the RPC host, create a .env file and point it at your hub gRPC host and port:

HUB_RPC=hostname:2283

About

A simple frame that displays a follower graph

License:MIT License


Languages

Language:Python 100.0%