đ Allow ListLearn how to build an Allow List for your Farcaster Frames based on various criterias by using the Airstack Frog Recipes.
You can limit access to your Farcaster Frame to only certain users that fulfill a requirement by creating an allow list based on certain criteria.
Get Started
First, install the Airstack Frog Recipes:
npm yarn pnpm bun
Copy npm install @airstack/frog hono
Copy yarn add @airstack/frog hono
Copy pnpm install @airstack/frog hono
Copy bun install @airstack/frog hono
createAllowList
You can create an allow list that checks various onchain data easily using the createAllowList
function. Some of the parameters that you can add to the allow list are:
Once you have the criteria set, the function will help you check whether all the criterias are fulfilled.
By default, it will only return true
for Farcaster users that satisfy ALL the given requirements. However, if you would like to check your user with a different logic, you can provide an optional custom isAllowedFunction
:
TypeScript JavaScript Response
Copy import {
createAllowList ,
CreateAllowListInput ,
CreateAllowListOutput ,
TokenBlockchain ,
} from "@airstack/frog" ;
const allowListCriteria = {
eventIds : [ 166577 ] ,
numberOfFollowersOnFarcaster : 100 ,
isFollowingOnFarcaster : [ 2602 ] ,
tokens : [
{
tokenAddress : "0x95cb845b525f3a2126546e39d84169f1eca8c77f" ,
chain : TokenBlockchain .Ethereum ,
} ,
{
tokenAddress : "0x2d45c399d7ca25341992038f12610c41a00a66ed" ,
chain : TokenBlockchain .Base ,
} ,
{
tokenAddress : "0x743658ace931ea241dd0cb4ed38ec72cc8162ce1" ,
chain : TokenBlockchain .Zora ,
} ,
] ,
};
const input : CreateAllowListInput = {
fid : 602 ,
allowListCriteria ,
isAllowedFunction : function (data) {
console .log (data);
return true ;
} ,
};
const { isAllowed , error } : CreateAllowListOutput = await createAllowList (
input
);
if (error) throw new Error (error);
console .log (isAllowed);
Copy const { createAllowList , TokenBlockchain } = require ( "@airstack/frog" );
const allowListCriteria = {
eventIds : [ 166577 ] ,
numberOfFollowersOnFarcaster : 100 ,
isFollowingOnFarcaster : [ 2602 ] ,
tokens : [
{
tokenAddress : "0x95cb845b525f3a2126546e39d84169f1eca8c77f" ,
chain : TokenBlockchain .Ethereum ,
} ,
{
tokenAddress : "0x2d45c399d7ca25341992038f12610c41a00a66ed" ,
chain : TokenBlockchain .Base ,
} ,
{
tokenAddress : "0x743658ace931ea241dd0cb4ed38ec72cc8162ce1" ,
chain : TokenBlockchain .Zora ,
} ,
] ,
};
const input = {
fid : 602 ,
allowListCriteria ,
isAllowedFunction : function (data) {
console .log (data);
return true ;
} ,
};
const { isAllowed , error } = await createAllowList (input);
if (error) throw new Error (error);
console .log (isAllowed);
Copy {
"isAllowed" : true ,
"error" : null
}
checkPoapAttendedByFarcasterUser
You can check if a Farcaster user has attended a given list of POAP event IDs by using the checkPoapAttendedByFarcasterUser
function:
TypeScript JavaScript Response
Copy import {
checkPoapAttendedByFarcasterUser ,
CheckPoapAttendedByFarcasterUserInput ,
CheckPoapAttendedByFarcasterUserOutput ,
} from "@airstack/frog" ;
const input : CheckPoapAttendedByFarcasterUserInput = {
fid : 15971 ,
eventId : [ 160005 , 159993 , 13242 ] ,
};
const { data , error } : CheckPoapAttendedByFarcasterUserOutput =
await checkPoapAttendedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy const { checkPoapAttendedByFarcasterUser } = require ( "@airstack/frog" );
const input = {
fid : 15971 ,
eventId : [ 160005 , 159993 , 13242 ] ,
};
const { data , error } = await checkPoapAttendedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy [
{ "eventId" : 160005 , "isAttended" : true } ,
{ "eventId" : 159993 , "isAttended" : true } ,
{ "eventId" : 13242 , "isAttended" : false }
]
checkTokenHoldByFarcasterUser
You can check if a Farcaster user is holding a given list of tokens across Ethereum, Base, Degen Chain, and other Airstack-supported chains by using the checkTokenHoldByFarcasterUser
function:
TypeScript JavaScript Response
Copy import {
checkTokenHoldByFarcasterUser ,
CheckTokenHoldByFarcasterUserInput ,
CheckTokenHoldByFarcasterUserOutput ,
TokenBlockchain ,
} from "@airstack/frog" ;
const input : CheckTokenHoldByFarcasterUserInput = {
fid : 15971 ,
token : [
{
chain : TokenBlockchain .Base ,
tokenAddress : "0x4c17ff12d9a925a0dec822a8cbf06f46c6268553" ,
} ,
{
chain : TokenBlockchain .Ethereum ,
tokenAddress : "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85" ,
} ,
{
chain : TokenBlockchain .Zora ,
tokenAddress : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
} ,
] ,
};
const { data , error } : CheckTokenHoldByFarcasterUserOutput =
await checkTokenHoldByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy import { checkTokenHoldByFarcasterUser , TokenBlockchain } from "@airstack/frog" ;
const input = {
fid : 15971 ,
token : [
{
chain : TokenBlockchain .Base ,
tokenAddress : "0x4c17ff12d9a925a0dec822a8cbf06f46c6268553" ,
} ,
{
chain : TokenBlockchain .Ethereum ,
tokenAddress : "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85" ,
} ,
{
chain : TokenBlockchain .Zora ,
tokenAddress : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
} ,
] ,
};
const { data , error } = await checkTokenHoldByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy [
{
"chain" : "base" ,
"tokenAddress" : "0x4c17ff12d9a925a0dec822a8cbf06f46c6268553" ,
"isHold" : false
} ,
{
"chain" : "ethereum" ,
"tokenAddress" : "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85" ,
"isHold" : true
} ,
{
"chain" : "zora" ,
"tokenAddress" : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
"isHold" : true
}
]
checkTokenMintedByFarcasterUser
You can check if a Farcaster user has minted a given list of tokens across Ethereum, Base, Degen Chain, and other Airstack-supported chains by using the checkTokenHoldByFarcasterUser
function:
TypeScript JavaScript Response
Copy import {
checkTokenMintedByFarcasterUser ,
CheckTokenMintedByFarcasterUserInput ,
CheckTokenMintedByFarcasterUserOutput ,
TokenBlockchain ,
} from "@airstack/frog" ;
const input : CheckTokenMintedByFarcasterUserInput = {
fid : 15971 ,
token : [
{
chain : TokenBlockchain .Base ,
tokenAddress : "0x57965af45c3b33571aa5419cc5e9012d8dcab181" ,
} ,
{
chain : TokenBlockchain .Ethereum ,
tokenAddress : "0xad08067c7d3d3dbc14a9df8d671ff2565fc5a1ae" ,
} ,
{
chain : TokenBlockchain .Zora ,
tokenAddress : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
} ,
] ,
};
const { data , error } : CheckTokenMintedByFarcasterUserOutput =
await checkTokenMintedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy const {
checkTokenMintedByFarcasterUser ,
TokenBlockchain ,
} = require ( "@airstack/frog" );
const input = {
fid : 15971 ,
token : [
{
chain : TokenBlockchain .Base ,
tokenAddress : "0x57965af45c3b33571aa5419cc5e9012d8dcab181" ,
} ,
{
chain : TokenBlockchain .Ethereum ,
tokenAddress : "0xad08067c7d3d3dbc14a9df8d671ff2565fc5a1ae" ,
} ,
{
chain : TokenBlockchain .Zora ,
tokenAddress : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
} ,
] ,
};
const { data , error } = await checkTokenMintedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy [
{
"chain" : "base" ,
"tokenAddress" : "0x57965af45c3b33571aa5419cc5e9012d8dcab181" ,
"isMinted" : true
} ,
{
"chain" : "ethereum" ,
"tokenAddress" : "0xad08067c7d3d3dbc14a9df8d671ff2565fc5a1ae" ,
"isMinted" : true
} ,
{
"chain" : "zora" ,
"tokenAddress" : "0xa15bb830acd9ab46164e6840e3ef2dbbf9c5e2b3" ,
"isMinted" : false
}
]
checkIsFollowingFarcasterUser
You can check if a Farcaster user is following a list of FIDs by using the checkIsFollowingFarcasterUser
function:
TypeScript JavaScript Response
Copy import {
checkIsFollowingFarcasterUser ,
CheckIsFollowingFarcasterUserInput ,
CheckIsFollowingFarcasterUserOutput ,
} from "@airstack/frog" ;
const input : CheckIsFollowingFarcasterUserInput = {
fid : 602 ,
isFollowing : [ 2602 , 15971 , 13242 ] ,
};
const { data , error } : CheckIsFollowingFarcasterUserOutput =
await checkIsFollowingFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy const { checkIsFollowingFarcasterUser } = require ( "@airstack/frog" );
const input = {
fid : 602 ,
isFollowing : [ 2602 , 15971 , 13242 ] ,
};
const { data , error } = await checkIsFollowingFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy [
{ "fid" : 2602 , "isFollowing" : true } ,
{ "fid" : 15971 , "isFollowing" : true } ,
{ "fid" : 13242 , "isFollowing" : false }
]
checkIsFollowedByFarcasterUser
You can check if a Farcaster user is being followed by a list of FIDs by using the checkIsFollowedByFarcasterUser
function:
TypeScript JavaScript Response
Copy import {
checkIsFollowedByFarcasterUser ,
CheckIsFollowedByFarcasterUserInput ,
CheckIsFollowedByFarcasterUserOutput ,
} from "@airstack/frog" ;
const input : CheckIsFollowedByFarcasterUserInput = {
fid : 602 ,
isFollowedBy : [ 2602 , 15971 , 13242 ] ,
};
const { data , error } : CheckIsFollowedByFarcasterUserOutput =
await checkIsFollowedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy const {
checkIsFollowedByFarcasterUser ,
CheckIsFollowedByFarcasterUserInput ,
CheckIsFollowedByFarcasterUserOutput ,
} = require ( "@airstack/frog" );
const input = {
fid : 602 ,
isFollowedBy : [ 2602 , 15971 , 13242 ] ,
};
const { data , error } = await checkIsFollowedByFarcasterUser (input);
if (error) throw new Error (error);
console .log (data);
Copy [
{ "fid" : 2602 , "isFollowedBy" : true } ,
{ "fid" : 15971 , "isFollowedBy" : true } ,
{ "fid" : 13242 , "isFollowedBy" : false }
]
Developer Support
If you have any questions or need help building an allow list for your Farcaster Frames using the Airstack Frog Recipe, please join our Airstack's Telegram group.
More Resources