# IFrictionlessPermissionsManager

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/interface/IFrictionlessPermissionsManager.sol)

**Author:** DEFYCA Labs S.à.r.l

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The IFrictionlessPermissionsManager is responsible for the management of permission of the various participants in the Frictionless protocol. The roles and responsibilities are defined in the public README for the Frictionless protocol at <https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/blob/main/README.md?ref\\_type=heads#roles-responsibilities>

## Functions

### isPermissioned

*Validates if a wallet address is permissioned in the Frictionless protocol*

```solidity
function isPermissioned(address userAddress) external view returns (bool);
```

**Parameters**

| Name          | Type      | Description                  |
| ------------- | --------- | ---------------------------- |
| `userAddress` | `address` | the wallet address to verify |

**Returns**

| Name     | Type   | Description                                                       |
| -------- | ------ | ----------------------------------------------------------------- |
| `<none>` | `bool` | true if the address is permissioned in the Frictionless Protocol. |

### registerIdentity

*Registers a users wallet address as an OnChainId (Identity) to the Frictionless protocol. This Identity is used when permissioning a user to the protocol by invoking the addUser function later.*

```solidity
function registerIdentity(address userAddress, uint16 userISOCountry) external returns (address);
```

**Parameters**

| Name             | Type      | Description                                                                                                                                                                                                                  |
| ---------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `userAddress`    | `address` | the address of the user's wallet to register                                                                                                                                                                                 |
| `userISOCountry` | `uint16`  | the ISO 3166-1 numeric code of the user, can be the place of residence or the location KYC/AML onboarding was undertaken. requires The msg.sender to have the TREX Agent permissions (PROTOCOL\_TREASURY or PROTOCOL\_ADMIN) |

**Returns**

| Name     | Type      | Description                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------- |
| `<none>` | `address` | address the address of the user's OnChainId (Identity) with the associated claims. |

### getIdentity

*Gets a users OnChainId (Identity) in the Frictionless protocol.*

```solidity
function getIdentity(address userAddress) external returns (address);
```

**Parameters**

| Name          | Type      | Description                                                                                                                                     |
| ------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `userAddress` | `address` | the address of the user's wallet to register requires The msg.sender to have the TREX Agent permissions (PROTOCOL\_TREASURY or PROTOCOL\_ADMIN) |

**Returns**

| Name     | Type      | Description                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------- |
| `<none>` | `address` | address the address of the user's OnChainId (Identity) with the associated claims. |

### getClaimMsgHash

*Get the signed claimData message to be used in the addUser function. The message must be signed using the PK of the ClaimIssuer (PROTOCOL\_ADMIN)*

```solidity
function getClaimMsgHash(address userIdentity, IFrictionlessPermissionsManager.FrictionlessPermissionedUser userType)
    external
    view
    returns (bytes32);
```

**Parameters**

| Name           | Type                                                           | Description                                    |
| -------------- | -------------------------------------------------------------- | ---------------------------------------------- |
| `userIdentity` | `address`                                                      | the address of the user's OnChainId (Identity) |
| `userType`     | `IFrictionlessPermissionsManager.FrictionlessPermissionedUser` | the type of the user as per the enum           |

**Returns**

| Name     | Type      | Description                                                                                   |
| -------- | --------- | --------------------------------------------------------------------------------------------- |
| `<none>` | `bytes32` | signed claimData message to be used in the addUser unction once signed by the ClaimIssuer PK. |

### hasClaim

*verify if the userAddress is permissioned in the Frictionless protocol and has a valid claim*

```solidity
function hasClaim(address userAddress, FrictionlessPermissionedUser userType) external view returns (bool);
```

**Parameters**

| Name          | Type                           | Description                                |
| ------------- | ------------------------------ | ------------------------------------------ |
| `userAddress` | `address`                      | the address of the user's wallet to verify |
| `userType`    | `FrictionlessPermissionedUser` | the type of the user as per the enum       |

**Returns**

| Name     | Type   | Description                                                               |
| -------- | ------ | ------------------------------------------------------------------------- |
| `<none>` | `bool` | true if a valid permissioned user and has a valid claim, otherwise false. |

### addUser

*Adds a user's OnChainId (Identity) to the Frictionless protocol along with its associated claim data. The Identity is created by invoking the registerIdentity function first.*

```solidity
function addUser(
    address userIdentity,
    FrictionlessPermissionedUser userType,
    bytes memory claimSignature,
    string memory claimURI
) external returns (address);
```

**Parameters**

| Name             | Type                           | Description                                                                                                                                                                                                                                                                                      |
| ---------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `userIdentity`   | `address`                      | the address of the user's OnChainId (Identity)                                                                                                                                                                                                                                                   |
| `userType`       | `FrictionlessPermissionedUser` | the type of the user as per the enum                                                                                                                                                                                                                                                             |
| `claimSignature` | `bytes`                        | the signed claimData by the ClaimIssuer                                                                                                                                                                                                                                                          |
| `claimURI`       | `string`                       | the URI of the off-chain claim for the user. i.e. The Frictionless Markets graphQL endpoint requires The msg.sender to be the Owner if the userType is the PROTOCOL\_TREASURY requires The msg.sender to have the TREX Agent permissions (PROTOCOL\_TREASURY or PROTOCOL\_ADMIN) to add any user |

**Returns**

| Name     | Type      | Description                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------- |
| `<none>` | `address` | address the address of the user's OnChainId (Identity) with the associated claims. |

### removeUser

*Removes a user from the Frictionless protocol along with its associated claim data.*

```solidity
function removeUser(address userAddress) external returns (bool);
```

**Parameters**

| Name          | Type      | Description                                                                                                                                            |
| ------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `userAddress` | `address` | the address of the user's wallet requires The msg.sender to have the TREX Agent permissions (PROTOCOL\_TREASURY or PROTOCOL\_ADMIN) to remove any user |

**Returns**

| Name     | Type   | Description                                                                                                       |
| -------- | ------ | ----------------------------------------------------------------------------------------------------------------- |
| `<none>` | `bool` | true if the user is removed from the Frictionless protocol along with its associated claim data, otherwise false. |

## Events

### FrictionlessPermissionedUserAdded

*Emitted when a user is added to the Frictionless protocol. This event is emitted by the `addUser` function.*

```solidity
event FrictionlessPermissionedUserAdded(address userIdentity, uint256 userType, string claimURI);
```

### FrictionlessPermissionedUserRegistered

*Emitted when a user is registered in the Frictionless protocol. This event is emitted by the `registerIdentity` function.*

```solidity
event FrictionlessPermissionedUserRegistered(address userAddress, uint16 userISOCountry);
```

### FrictionlessPermissionedUserRemoved

*Emitted when a user is removed in the Frictionless protocol. This event is emitted by the `removeUser` function.*

```solidity
event FrictionlessPermissionedUserRemoved(address userAddress);
```

## Errors

### FrictionlessIsZeroAddress

*throws if specific address is zero.*

```solidity
error FrictionlessIsZeroAddress(string);
```

### FrictionlessInvalidPermissionForTreasury

*throws if treasury tries to add or remove treasury.*

```solidity
error FrictionlessInvalidPermissionForTreasury();
```

### FrictionlessUserIsNotPermssionedInvestor

*throws if user is not a permissioned investor*

```solidity
error FrictionlessUserIsNotPermssionedInvestor();
```

## Structs

### Claim

*the internal struct defining a Claim for a PERMISSIONED\_USER in the protocol. Used to submit claims for the OnChainId by the ClaimIssuer.*

```solidity
struct Claim {
    address issuer;
    uint256 topic;
    uint8 scheme;
    address identity;
    bytes signature;
    bytes data;
}
```

## Enums

### FrictionlessPermissionedUser

*Enum of the Frictionless protocol participants.*

```solidity
enum FrictionlessPermissionedUser {
    PROTOCOL_TREASURY,
    PERMISSIONED_CUSTODIAN,
    PERMISSIONED_INVESTOR,
    PERMISSIONED_MANAGER,
    PERMISSIONED_CALCULATING_AGENT,
    PERMISSIONED_TRANSFER_AGENT,
    PERMISSIONED_FUND_ACCOUNTANT
}
```


---

# 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.frictionless.markets/developer/smart-contracts/smart-contract-docs/manager-contracts/ifrictionlesspermissionsmanager.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.
