DEV Community

Cover image for How to Token Gate with POAP
Jennifer K. Tran
Jennifer K. Tran

Posted on

How to Token Gate with POAP

This article outlines how to utilize Proof of Attendance Protocol’s (POAP) APIs to create a natively token gated application. Note that MintGate has a direct integration with POAP via the same APIs for our no-code token gating solution.

What is Proof of Attendance or POAP?

Proof of Attendance Protocol (POAP) provides event nomads with a way to verify their attendance through collecting digital badges, all of which live on-chain.

What is token gating?

Token gating is when ownership of an NFT or social token is required to access content. Think of it as a creator or community creates a blockchain token and then sets up a paywall that only
accepts that token to access exclusive content.

Other terms to describe token gating include NFT access and NFT tickets.

Why token gating with POAP? (Use Cases)

Token gating with POAP means that an event host only allows event attendees who own a POAP badge to access certain content post-event. Gating content with a POAP badge enables event hosts to create unique experiences and build longer term relationships with event attendees.

Several use cases include:

  • Only virtual call attendees can access the recorded call
  • Attendees of an IRL event can access a site to claim swag
  • Only attendees of a past event can RSVP to attend another event
  • And More!

How to Utilize POAP’s APIs?

Note that MintGate has a direct integration with POAP via the same APIs for our no-code token gating solution. Try it out at app.mintgate.io/create_link -> Input your URL and description -> Choose POAP as the blockchain.

How Creating a Token Gating App Works
In order to develop a token gated content platform, you ask a user for a wallet address, store the wallet address, and then pass it into an API that can check the user’s balance of the NFT or
token.

With Ethereum and EVM-based chains, you can utilize a wallet connection modal such as BlockNative Onboard or Web3Modal, store the wallet address that is returned, and use a blockchain connection API such as Infura to check token balances.

Working with POAP
Though POAPs are minted on xDAI, an EVM-based chain, POAP holders of the same event can have various different NFTs. As a result, it is difficult to check all of the NFTs using an API that can connect to the blockchain.

Instead, you can should check if a user owns a POAP by the POAP Event ID. The POAP Event ID is a set of numbers that identifies the event.

You can find a POAP Event ID by going to poap.gallery, searching for the POAP, and the event ID is the numbers with the # in front.

Example of POAP Search Result with POAP Event ID highlighted

You can utilize POAP’s {address}/{eventID} endpoint to check if a wallet address owns a wallet by a POAP Event ID.

Here is an example code to check if a wallet address owns a POAP by Event ID:

             async checkBalance(wallet:string, eventID:string, req, res):Promise<boolean> {
    const url = 
       `http://api.poap.xyz/actions/scan/${wallet}/${eventID}`

            const result = await fetch(url).then(x=>x.json());

            if(!result) {
                 console.error('No POAP Information available');
                 return false;
             }

            const message = result.message;
            const eventValid = result.event;

    if (result.status == '404' || message == 'Address does not have token for this event') {
        return false;`
    } else if (eventValid) {
        return true;
    }
Enter fullscreen mode Exit fullscreen mode

The API enables you to easily check balances of a POAP without utilizing more complicated APIs that connect to the blockchain.

Token gating post-event assets by POAP enables event hosts to create unique experiences for event attendees. Hope that you consider token gating via POAP soon!

Top comments (0)