Token-gating using badges
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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.
You can use our to fetch all the badge owners of that 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
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.
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.