🔏Token-gating using badges
Token gating by Badge spec implies that only holders of Badges belonging to one or more specs are able to get through the token gate.
Finding the badge spec id
First, you need to get the id of the Badge Spec that you used to issue badges to different addresses.
You can find the Badge spec id in the url of the Badge page.
Fetching all the holders of a badge spec
You can use our subgraph to fetch all the badge owners of that spec
Does an address hold a Badge belonging to this spec?
If you already know the address of a user, you can simply check if this address owns a badge with the spec that you intend to gate. For example, see the query below. Here we’re checking if the address 0x77B476429826C5ba77885D08F272d89D8F1Ed0e4
owns a Pioneer badge issued by the Otterspace Raft.
And if you’d like to check if an address owns one of the badges, simply use spec_in
filter
Filtering out expired and revoked Badges
One thing that makes Badges different from other NFTs is that they can expire. Expired Badges shouldn’t be able to be used to access spaces and resources. You can check if a Badge is expired by looking at the expiry date in the metadata.
Filtering by community
If you are building a token-gating UI, you probably want to allow an account admin to select from the Badge Specs belonging to that account.
The unique identifier of a Raft is the Token Id of an ERC721 token which is airdropped to the community during its formation. The Raft Id can be found in the community’s profile url.
Last updated