ChannelKit is an open-source Next.js application built with Frog.js and deployed on Vercel, providing a customizable Farcaster Frame for managing channel memberships. Designed for developers, it offers a flexible foundation for creating and managing membership requests to Farcaster channels.
- Node.js (v22 or later)
- Yarn package manager
- Farcaster account
- Neynar API key
- Vercel account
- Vercel CLI
- Channel owner deploys this project to Vercel
- Channel owner casts frame in channel, optionally pins for better visibility
- Prespective member clicks "Request Membership" button on frame
- Verifications run in background, and automatically output an accepted / denied state - If accepted, user is automatically sent an invite - If denied message is shown with reasoning
- If you want to use the provided verification modules as-is:
git clone https://github.com/yourusername/channel-kit.git cd channel-kit
- If you want to add modules, customize extensively, or contribute to the codebase:
yarn install
Copy the .env.example
file to .env.local
and fill in the required values:
cp .env.example .env.local
Edit .env.local
and provide values for:
CHANNEL_ID=your_channel_id
NEYNAR_API_KEY=your_neynar_api_key
If you already have the UUID of a Neynar managed signer, you can add it to the .env.local
file:
SIGNER_UUID=your_signer_uuid
If you do not have a signer UUID, see Creating a Neynar Managed Signer
yarn dev
The application will be available at http://localhost:3000/api/dev
.
When ready, we can deploy our application:
yarn run deploy
Add our environment variables and redeploy:
yarn run upload-env
Your project should now be live!
Let's first grab the URL of our Frame from the Vercel Dashboard:
Alternatively, you can run this command and get the first alias:
yarn vercel inspect [deployment-url]
Now we can head to the Warpcast frame validator and paste the URL to see our live Frame:
https://warpcast.com/~/developers/frames
ChannelKit comes with a set of basic verifications to determine user eligibility for channel membership. These verifications are modular and can be easily customized or extended.
isPowerUser
: Checks if the user has a power badge on Warpcast.(commented out by default)hasVerifiedEthAddress
: Verifies if the user has a verified Ethereum address.hasVerifiedSolAddress
: Verifies if the user has a verified Solana address.(commented out by default)hasMoreThan100Followers
: Checks if the user has more than 100 followers.hasCastedMoreThan10Times
: Verifies if the user has cast more than 10 times in the channel (commented out by default).hasProfileRankBelow200
: Checks if the user's OpenRank profile rank is below 200 (commented out by default).isSubscribedWithSTP
: Verifies if the user is subscribed with STP (Subscription Token Protocol) (commented out by default).
Developers are encouraged to add their own custom verifications based on their specific requirements
Example of a custom verification:
export const hasSpecificBadge: VerificationFunction = async (
fid: number
): Promise<VerificationResult> => {
// Implement your verification logic here
return { success: true, message: "User has the specific badge" }
}
Then add it to the verificationFunctions
array:
const verificationFunctions: VerificationFunction[] = [
// ... existing verifications
hasSpecificBadge,
]
- Modify the verification criteria in
verifications/index.ts
- Adjust the UI components in the
ui/
directory - Update the Frame logic in
app/api/[[...routes]]/route.tsx
This project uses a combination of custom styles and FrogUI. Due to some idiosyncrasies (such as custom fonts) with
Frog.js, Hono, and NextJS, you might find that either custom styles or FrogUI works where the other doesn't. All custom styles can be found
in ui/styles.ts
, and all FrogUI elements can be found in ui/index.ts
ChannelKit is intended to be a community project! Contributions are welcome following these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License.
If you do not have a signer UUID, you can create one by adding your Farcaster mnemonic to the .env.local
file. Whether you use your personal mnemonic or create a new account specifically for this purpose is up to you
FARCASTER_MNEMONIC=your_farcaster_mnemonic
Then, run the following command and follow the prompts to approve the signer in the Warpcast mobile app:
yarn run create-signer
This will create a new signer and output the UUID to the .env.local
file, as well as
the console. It is recommended to save this UUID in case the signer is not approved, or
to re-use the same signer for multiple channels.
-
Data Fetching (
data/farcaster.ts
):- This file contains functions for fetching data from the Farcaster API via Neynar.
- It includes methods like
getChannelMembers()
,getUser()
, andgetUserCasts()
. - These functions handle the raw API calls and return structured data.
-
Verification Logic (
verifications/farcaster.ts
):- This file contains the actual verification functions that use the data fetched from
data/farcaster.ts
. - Each verification function implements a specific check, such as
isPowerUser
orhasMoreThan100Followers
. - These functions use the
VerificationFunction
type and return aVerificationResult
.
- This file contains the actual verification functions that use the data fetched from
This separation allows you to:
- Add new API calls in
data/farcaster.ts
without changing the verification logic. - Create new verification functions in
verifications/farcaster/index.ts
that use existing or new data fetching methods. - Easily extend the system with new data sources or verification providers by adding new files in the
data/
andverifications/
directories.
When customizing:
- If you need new data either from an API or onchain, add a function to
data/farcaster.ts
. - To create a new verification, add a function to
verifications/farcaster/index.ts
and use the data fetching functions as needed. - Add your new verification function to the
verificationFunctions
array inverifications/index.ts
to include it in the verification process.
This modular approach allows you to easily extend and modify the verification system to suit your specific channel membership criteria.