DEV Community

Cover image for Token Gating Websites with Collab.Land
Ekene Eze (Kenny)
Ekene Eze (Kenny)

Posted on • Originally published at


Token Gating Websites with Collab.Land

Token gating is the idea of using tokens as a means of verifying membership or access to a community or resource. This can be done by requiring users to possess certain tokens in order to join a community or access certain resources.

This concept has gained significant traction in recent years, particularly within decentralized autonomous organizations (DAOs) and non-fungible token (NFT) communities. At its core, token gating involves using tokens to grant or restrict access to a community or resource. In this blog post, we'll explore the history, use cases, advantages, challenges, and future of token gating. We’ll also explore the possibilities of extending its current usage to cater for developers building for the web.

Yesterday, Collab.Land announced a new /access-control endpoint for its token gating API that allows developers to control access to their websites and web applications based on the possession of specific tokens.

The endpoint accepts two parameters:

account - The wallet address of the user.

rules - The token gating rules that specifies the token(s) to look for in the users address.

For each rule, Collab.Land will return a response indicating whether or not the rule has been granted or denied for the user. Here’s a sample request to the Collab.Land /access-control endpoint:



  "account": "0x01c20350ad8f434bedf6ea901203ac4cf7bca295",
  "rules": [
      "type": "ERC721",
      "chainId": 1,
      "minToken": "1",
      "contractAddress": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
      "roleId": "001"
Enter fullscreen mode Exit fullscreen mode

Where account represents the users wallet address and rules is an array of objects representing each rule to be checked against the users wallet.

This call would return a sample response like this:

  "roles": [
      "id": "001",
      "granted": true
Enter fullscreen mode Exit fullscreen mode

To learn more about the Collab.Land token gating APIs, please read the official documentation or dive into a practical tutorial to build a gated website in minutes. You can also get your hands dirty with the Github repo. Want to build a token-gated website with JavaScript? here’s a sample code snippet to call the Collab.Land TGR endpoint using fetch:

const res = await fetch(``, {
method: 'POST',
headers: new Headers({
    Accept: 'application/json',
    'X-API-KEY': process.env.COLLABLAND_KEY,
    'Content-Type': 'application/json',
body: JSON.stringify({
    account: myWalletAddr,
    rules: [
Enter fullscreen mode Exit fullscreen mode

Using the website token gating APIs, Collab.Land extends the successful patterns of token-granted access to communities and DAOs to the web. You can learn how to build a token-gated website here or watch the video tutorial below

Top comments (0)

The AI Brief

AI generated git commit messages

Minimize the struggle of remembering what you just coded. AI-generated commits make it easier to manage projects and keep track of changes. The Nutlope/aicommits project demonstrates how AI can improve commit messages.

I open sourced an AI that creates any UI in seconds

Make AI-generated user interfaces a breeze. This open-source project harnesses the power of generative AI technologies like chatGPT to create versatile, quick, and intuitive UI components.

Use AI to commit like a PRO in 1 second

Upgrade your commit message game with AI. Boost your productivity by using ChatGPT to generate commit messages and avoid context switching. OpenCommit is an open-source library that helps you achieve this easily.

Build your own ChatGPT starter kit

Train AI models on custom data for improved domain-specific knowledge. Combine the power of WebView technologies and this starter kit to train your ChatGPT model on specific websites, allowing for better-optimized outcomes.