Understanding Conditional Gating in Group Chat

xavierop877

Abhishek Tripathi

Posted on March 9, 2024

Understanding Conditional Gating in Group Chat

Introduction

Managing who has access to group chats and making sure that conversations remain private and secure are essential in today's online communities. A strong method for managing who may join a group and transmit messages inside it is conditional gating. This technical overview explores the components, features, and real-world applications of conditional gating.

What is Conditional Gating?

A particular method for defining policies for group membership and message rights based on specific conditions is conditional gating. These requirements could be being the owner of tokens, having non-fungible tokens (NFTs), taking part in particular events, or fulfilling other established criteria. It makes it possible to build dynamic communities with customized access restrictions.

Components of Conditional Gating

  • Rules Object: The basic element of conditional gating is the rule object. It has restrictions and requirements that set the group members' rights. Every permission in the rules object specifies a certain capability, like chat or entry.
  • Permissions: The rights connected to group membership or messaging are defined by permissions. These consist of chat permission, which manages messaging inside the group, and being accepted permission, which regulates entering the group.
  • Conditions: The requirements that must be met in order for a permit to be granted are known as conditions. They are made up of one or more criteria objects that specify certain needs, including possessing a token, taking part in events, or reaching particular standards.
  • Criteria: Criteria specify the particular requirements that must be fulfilled in order for permission to be granted. They can define criteria like token ownership, contract addresses, comparison operators, and data values. They cover a variety of access control methods, including PUSH and GUILD kinds.

Practical Examples

Token Gated Group
Problem Statement: Create a group accessible only to users who hold a certain number of tokens.
Solution: Define criteria requiring users to hold a specified amount of tokens on Ethereum or Polygon networks. Use the rules object to enforce these conditions for entry into the group.

// Token Gated Group Criteria
const ethereumCriteria = {
  type: "PUSH",
  category: "ERC20",
  subcategory: "holder",
  data: {
    contract: "eip155:1:0xf418588522d5dd018b425E472991E52EBBeEEEEE", // $PUSH address on Ethereum
    comparison: ">=",
    amount: 1,
    decimals: 18,
  },
};

const polygonCriteria = {
  type: "PUSH",
  category: "ERC20",
  subcategory: "holder",
  data: {
    contract: "eip155:137:0x58001cC1A9E17A20935079aB40B1B8f4Fc19EFd1", // $PUSH address on Polygon
    comparison: ">=",
    amount: 1,
    decimals: 18,
  },
};

// Decider object - 'any' since either condition should allow access
const tokenGatingDecider = {
  any: [ethereumCriteria, polygonCriteria],
};

// Rules object
const tokenGatingRules = {
  entry: {
    conditions: tokenGatingDecider,
  },
};

Enter fullscreen mode Exit fullscreen mode

Multi-Chain Conditions
Problem Statement: Allow users to join a group if they meet specific criteria on multiple blockchain networks.

Solution: Define conditions for each blockchain network, specifying token ownership requirements. Use the any decider to allow entry if the user meets the criteria on any supported network.

// Multi-Chain Conditions
// Define conditions for Ethereum and Polygon networks

// Ethereum criteria
const ethereumCriteria = {
  type: "PUSH",
  category: "ERC20",
  subcategory: "holder",
  data: {
    contract: "eip155:1:0xf418588522d5dd018b425E472991E52EBBeEEEEE", // $PUSH address on Ethereum
    comparison: ">=",
    amount: 1,
    decimals: 18,
  },
};

// Polygon criteria
const polygonCriteria = {
  type: "PUSH",
  category: "ERC20",
  subcategory: "holder",
  data: {
    contract: "eip155:137:0x58001cC1A9E17A20935079aB40B1B8f4Fc19EFd1", // $PUSH address on Polygon
    comparison: ">=",
    amount: 1,
    decimals: 18,
  },
};

// Decider object - 'any' since either condition should allow access
const multiChainDecider = {
  any: [ethereumCriteria, polygonCriteria],
};

// Rules object
const multiChainRules = {
  entry: {
    conditions: multiChainDecider,
  },
};

Enter fullscreen mode Exit fullscreen mode

Non-Web3 Conditionns
Problem Statement: Grant access to a group based on actions taken outside of the blockchain ecosystem, such as following a social media account.

Solution: Utilize criteria that check for specific actions, such as following a Twitter account. Integrate these criteria into the rules object to enable conditional gating based on non-web3 activities.

// Non-Web3 Conditions
// Define criteria for following a Twitter account

const twitterCriteria = {
  type: "GUILD",
  category: "TWITTER",
  subcategory: "FOLLOW",
  data: {
    username: "@pushprotocol",
  },
};

// Rules object
const nonWeb3Rules = {
  entry: {
    conditions: {
      any: [twitterCriteria],
    },
  },
};

Enter fullscreen mode Exit fullscreen mode

Conclusion

Using conditional gating to manage access limits in group conversations is a flexible and reliable solution. Community managers may design dynamic settings that are customized to meet their unique needs by utilizing rules, permissions, conditions, and requirements. With conditional gating, you may create safe and welcoming online communities using token gating, multi-chain restrictions, and non-web3 criteria.

💖 💪 🙅 🚩
xavierop877
Abhishek Tripathi

Posted on March 9, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related