🎭Allow List

Learn 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 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:

NameTypeDescription

eventIds

number[]

POAP Gating – Check If POAPs with the given event IDs are attended by a Farcaster user.

numberOfFollowersOnFarcaster

number

Check If the number of Farcaster followers greater than or equal to the given number.

isFollowingOnFarcaster

number[]

Check if the given FIDs are being followed by a Farcaster user.

tokens

{tokenAddress: string; chain: TokenBlockchain;}[]

Token Gating – Check If tokens are currently held by a Farcaster user.

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:

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);

checkPoapAttendedByFarcasterUser

You can check if a Farcaster user has attended a given list of POAP event IDs by using the checkPoapAttendedByFarcasterUser function:

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);

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:

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);

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:

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);

checkIsFollowingFarcasterUser

You can check if a Farcaster user is following a list of FIDs by using the checkIsFollowingFarcasterUser function:

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);

checkIsFollowedByFarcasterUser

You can check if a Farcaster user is being followed by a list of FIDs by using the checkIsFollowedByFarcasterUser function:

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);

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

Last updated