🎭Allow List

Learn how to build an Allow List for your Farcaster Frames based on various criterias by using the Airstack Frames SDK.

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

Create A Custom Allow List

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/frames";

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

Check If POAP(s) Is Attended By A Farcaster User

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/frames";

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

Check If Token(s) Hold By A Farcaster User

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/frames";

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

Check If Token(s) Minted By A Farcaster User

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/frames";

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

Check If User Is Following Farcaster User(s)

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

import {
  checkIsFollowingFarcasterUser,
  CheckIsFollowingFarcasterUserInput,
  CheckIsFollowingFarcasterUserOutput,
} from "@airstack/frames";

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

Check If User Is Followed By Farcaster User(s)

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/frames";

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

Check If Farcaster User Has Any Non-Virtual POAPs

You can check if the Farcaster user has attended any non-virtual or in-real-life (IRL) POAP events by providing the Farcaster user's fid from the Frame Signature Packet to the $farcasterUser variable using the Poaps API:

Try Demo

Code

query POAPsOwned($farcasterUser: Identity!) {
  Poaps(
    input: {
      filter: { owner: { _eq: $farcasterUser } }
      blockchain: ALL
      limit: 50
    }
  ) {
    Poap {
      mintOrder
      mintHash
      poapEvent {
        isVirtualEvent
      }
    }
    pageInfo {
      nextCursor
      prevCursor
    }
  }
}

Check If Farcaster User Has Certain POAP(s)

You can check if the Farcaster user has attended certain POAP event(s) by using the checkPoapAttendedByFarcasterUser function:

import {
  checkPoapAttendedByFarcasterUser,
  CheckPoapAttendedByFarcasterUserInput,
  CheckPoapAttendedByFarcasterUserOutput,
} from "@airstack/frames";

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

Check If Farcaster User Has X or More Followers on Farcaster

You can check if the Farcaster user has X or more Farcaster followers by providing the Farcaster user's fid from the Frame Signature Packet to the $farcasterUser variable using the Socials API:

Try Demo

Code

query MyQuery($farcasterUser: Identity!) {
  Socials(
    input: {
      filter: {
        followerCount: { _gt: 100 }
        dappName: { _eq: farcaster }
        identity: { _eq: $farcasterUser }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      followerCount
    }
  }
}

Check If Farcaster User Is Followed By Certain High Profile Users

You can check if the Farcaster user is followed by certain high profile users, e.g. vitalik.eth, jessepollak, etc., by using the checkIsFollowedByFarcasterUser function:

import {
  checkIsFollowedByFarcasterUser,
  CheckIsFollowedByFarcasterUserInput,
  CheckIsFollowedByFarcasterUserOutput,
} from "@airstack/frames";

const input: CheckIsFollowedByFarcasterUserInput = {
  fid: 602,
  isFollowedBy: [
    99, // jessepollak
    5650, // vitalik.eth
  ],
};
const { data, error }: CheckIsFollowedByFarcasterUserOutput =
  await checkIsFollowedByFarcasterUser(input);

if (error) throw new Error(error);

console.log(data);

Check If Farcaster User Hold Any High Value NFTs

You can check if the Farcaster user has any high value NFTs, e.g. BAYC, by using the checkTokenHoldByFarcasterUser function:

import {
  checkTokenHoldByFarcasterUser,
  CheckTokenHoldByFarcasterUserInput,
  CheckTokenHoldByFarcasterUserOutput,
  TokenBlockchain,
} from "@airstack/frames";

const input: CheckTokenHoldByFarcasterUserInput = {
  fid: 21018,
  token: [
    {
      chain: TokenBlockchain.Ethereum,
      tokenAddress: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
    },
  ],
};
const { data, error }: CheckTokenHoldByFarcasterUserOutput =
  await checkTokenHoldByFarcasterUser(input);

if (error) throw new Error(error);

console.log(data);

Check If Farcaster User Follows The Creator Of The Frames

You can check if the Farcaster user follows the Frames' creator by using the checkIsFollowingFarcasterUser function:

import {
  checkIsFollowingFarcasterUser,
  CheckIsFollowingFarcasterUserInput,
  CheckIsFollowingFarcasterUserOutput,
} from "@airstack/frames";

const input: CheckIsFollowingFarcasterUserInput = {
  fid: 3,
  isFollowing: [99],
};
const { data, error }: CheckIsFollowingFarcasterUserOutput =
  await checkIsFollowingFarcasterUser(input);

if (error) throw new Error(error);

console.log(data);

Check If Farcaster User Transacted On Certain Blockchain Before Certain Date

You can check if the Farcaster user transacted on certain blockchain, e.g. Ethereum, Base, Degen Chain, and other Airstack-supported chains by providing the Farcaster user's fid from the Frame Signature Packet to the $farcasterUser variable and the before date to check to the $beforeDate variable using the Wallet API:

Try Demo

Code

query MyQuery($farcasterUser: Identity!, $beforeDate: Time!) {
  TokenTransfers(
    input: {
      filter: {
        from: { _eq: $farcasterUser }
        blockTimestamp: { _lt: $beforeDate }
      }
      blockchain: ethereum
    }
  ) {
    TokenTransfer {
      transactionHash
      blockTimestamp
    }
  }
}

Check If Farcaster User Has Casted In A Given Channel

You can check if Farcaster user has casted in a given channel by using the FarcasterChannelParticipants API and providing:

  • the "cast" value to the $channelActions variable,

  • the channel ID (e.g. /farcaster channel ID is "farcaster") to $channelId variable, and

  • the FID to the $participant variable

Try Demo

Code

query MyQuery {
  FarcasterChannelParticipants(
    input: {
      filter: {
        participant: { _eq: "fc_fid:602" }
        channelId: { _eq: "airstack" }
        channelActions: { _eq: cast }
      }
      blockchain: ALL
    }
  ) {
    FarcasterChannelParticipant {
      lastActionTimestamp
    }
  }
}

Check If Farcaster User Has A Power Badge

You can check if Farcaster user has a power badge by using the Socials API:

Try Demo

Code

query MyQuery {
  Socials(
    input: {
      filter: { identity: { _eq: "fc_fid:602" }, dappName: { _eq: farcaster } }
      blockchain: ethereum
    }
  ) {
    Social {
      isFarcasterPowerUser
    }
  }
}

Developer Support

If you have any questions or need help building an allow list for your Farcaster Frames using the Airstack Frames SDK, please join our Airstack's Telegram group.

More Resources

Last updated