# Blocking

### Table of Contents

* [Events](#events)
* [Black & White Lists](#black-and-white-lists)

***

## <mark style="color:purple;">Events</mark>

### toggleWhiteListLog

Emits when the using of a whitelist is toggled on/off.

### logWhitelistUpdate

Emits when a whitelist is updated.

### logBlacklistUpdate

Emits when a blacklist is updated.

### logNFTReqUpdate

Emits when the requirements for a poster to own a minimum amount of NFTs to be able to post in a group are updated.

***

## <mark style="color:purple;">Black & White Lists</mark>

Whitelist = NO ONE can message owner EXCEPT for addresses explicitly allowed here by the owner.&#x20;

Blacklist = EVERYONE can message owner EXCEPT for addresses explicitly blocked here by the owner.&#x20;

### isAllowedByNFT

Checks to see if the group is using NFT whitelisting and if so, do they have the minimum required amount of tokens from the ERC20 / ERC721 / ERC1155 contract to be allowed to post into the group.

**Parameters**

| Parameter        | Type    | Description                                             |
| ---------------- | ------- | ------------------------------------------------------- |
| requesterAddress | address | User or group address requesting to post into the group |
| groupAddress     | address | The group that the requester wants to post into         |

**Returns**

| Parameter | Type | Description                                                         |
| --------- | ---- | ------------------------------------------------------------------- |
| output    | bool | True if the requester is allowed to perform action, False otherwise |

**Example**

```javascript
const ethers = require('ethers');
const requesterAddress = ethers.constants.AddressZero;
const groupAddress = ethers.constants.AddressZero;
const isAllowedByNFT = await contract.isAllowedByNFT(requesterAddress, groupAddress);
```

***

### isAllowed

Checks to see if the requesterAddress is allowed to perform actions against targetAddress.

**Parameters**

| Parameter        | Type    | Description                                                                 |
| ---------------- | ------- | --------------------------------------------------------------------------- |
| requesterAddress | address | User or group address requesting to perform an action to a user or group    |
| targetAddress    | address | User or group address that the requester wants to perform an action against |

**Returns**

| Parameter | Type | Description                                                         |
| --------- | ---- | ------------------------------------------------------------------- |
| output    | bool | True if the requester is allowed to perform action, False otherwise |

**Example**

```javascript
const ethers = require('ethers');
const requesterAddress = ethers.constants.AddressZero;
const targetAddress = ethers.constants.AddressZero;
const isAllowed = await contract.isAllowed(requesterAddress, targetAddress);
```

***

### getList

Get a list of user addresses that are either blocked (when using a blacklist) or allowed (when using a whitelist).

**Parameters**

| Parameter  | Type    | Description                                                         |
| ---------- | ------- | ------------------------------------------------------------------- |
| usrAddress | address | The address of the user to get the black or whitelist of users from |
| blackList  | bool    | True for black list, False for white list                           |
| startFrom  | uint256 | Used or paginating through the results                              |

**Returns**

| Parameter | Type       | Description                               |
| --------- | ---------- | ----------------------------------------- |
| output    | address\[] | An array of addresses in the list queried |

**Example**

```javascript
const ethers = require('ethers');
const usrAddress = ethers.constants.AddressZero;
const blackList = true;
const startFrom = 0;
const getList = await contract.getList(usrAddress, blackList, startFrom);
```

***

### toggleWhiteList

Toggle the using of a whitelist on / off. Can be used for groups as well if a groupID is passed, only the group owner can perform this function.

**Parameters**

| Parameter | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| groupID   | uint256 | Can pass in if this is a group being managed, otherwise pass in 0 for a user |

**Example**

```javascript
const ethers = require('ethers');
const groupID = 0;
await contract.toggleWhiteList(groupID);
```

***

### updateNFTReq

Require a poster to own a minimum amount of NFTs (ERC 20 / 721 / 1155) to be able to post in your group. Can only be called by Group owners.

**Parameters**

| Parameter       | Type    | Description                                                                                |
| --------------- | ------- | ------------------------------------------------------------------------------------------ |
| contractAddress | address | Address of the NFT contract (0x0 disables requirement)                                     |
| minimumReq      | uint256 | Minimum amount of NFTs owned by wallet from contractAddress to be allowed to post in group |
| groupID         | uint256 | Group ID to Apply to                                                                       |

**Example**

```javascript
const ethers = require('ethers');
const contractAddress = ethers.constants.AddressZero;
const minimumReq = 0;
const groupID = 0;
await contract.updateNFTReq(contractAddress, minimumReq, groupID);
```

***

### updateWhitelist

Toggle an address to be on / off the whitelist. If a groupID is passed, only the group owner can perform this function.

**Parameters**

| Parameter | Type    | Description                                                                  |
| --------- | ------- | ---------------------------------------------------------------------------- |
| toToggle  | address | Address of user or group                                                     |
| groupID   | uint256 | Can pass in if this is a group being managed, otherwise pass in 0 for a user |

**Example**

```javascript
const ethers = require('ethers');
const toToggle = ethers.constants.AddressZero;
const groupID = 0;
await contract.updateWhitelist(toToggle
```

***

### updateBlacklist

This function is used to manage an address or group in the blacklist. The blacklist includes addresses or groups which are denied to message the owner. This function could be performed only by the group owner. An address or group can be added to or removed from the blacklist. If it's already added, it would be removed, and if it's not added, it would be added to the list.

#### Expected Inputs

| Name     | Type    | Description                                                             |
| -------- | ------- | ----------------------------------------------------------------------- |
| toToggle | address | The address of the user or group to be managed.                         |
| groupID  | uint256 | The ID of the group being managed. Pass 0 if it's a user being managed. |

#### Returns

No return value.

#### Code Sample

```javascript
const contract = new ethers.Contract(contractAddress, abi, wallet);

const toToggle = '0x4bEDE3ba9EA10C4D54546cAe2091ed1B758Aceee'; // Example address
const groupID = 0; // Group ID if applicable, 0 if a user

async function toggleBlacklist() {
  const tx = await contract.updateBlacklist(toToggle, groupID);
  console.log(`Transaction Hash: ${tx.hash}`);
  const receipt = await tx.wait();
  console.log(`Transaction was mined in block ${receipt.blockNumber}`);
}

toggleBlacklist();
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kuthulu.xyz/contracts/blocking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
