# BBTiers

{% embed url="<https://github.com/backedby/v1-contracts/blob/main/contracts/BBTiers.sol>" %}

## Functions

### createTiers

```solidity
function createTiers(
    uint256 profileId, 
    uint256[] calldata prices, 
    string[] calldata cids, 
    bool[] memory deprecated, 
    address[] calldata supportedCurrencies, 
    uint256[] calldata priceMultipliers
) external returns (uint256 tierSetId)
```

Creates a set of tiers

#### Parameters

| Name                | Type       | Description                                    |
| ------------------- | ---------- | ---------------------------------------------- |
| profileId           | uint256    | ID of the profile to create the tier set in    |
| prices              | uint256\[] | The base prices of each tier                   |
| cids                | string\[]  | The CID's of each tier                         |
| deprecated          | bool\[]    | The deprecation state of each tier             |
| supportedCurrencies | address\[] | Contract address of each supported ERC20 token |
| priceMultipliers    | uint256\[] | Price multiplier of each supported ERC20 token |

#### Return Values

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| tierSetId | uint256 | The ID of the created tier set |

### editTiers

```solidity
function editTiers(
    uint256 profileId, 
    uint256 tierSetId, 
    uint256[] calldata prices, 
    string[] calldata cids, 
    bool[] memory deprecated
) external
```

Set the values of a set of tiers

#### Parameters

| Name       | Type       | Description                               |
| ---------- | ---------- | ----------------------------------------- |
| profileId  | uint256    | ID of the profile to edit the tier set in |
| tierSetId  | uint256    | The ID of the tier set to edit            |
| prices     | uint256\[] | New prices of each tier                   |
| cids       | string\[]  | New CID's of each tier                    |
| deprecated | bool\[]    | New deprecated state of each tier         |

### setSupportedCurrencies

```solidity
function setSupportedCurrencies(
    uint256 profileId, 
    uint256 tierSetId, 
    address[] calldata supportedCurrencies, 
    uint256[] calldata priceMultipliers
) external
```

Set a tier sets supported ERC20 tokens for payment&#x20;

#### Parameters

| Name                | Type       | Description                                          |
| ------------------- | ---------- | ---------------------------------------------------- |
| profileId           | uint256    | ID of the profile to set the supported currencies in |
| tierSetId           | uint256    | Tier set ID to set the supported currencies in       |
| supportedCurrencies | address\[] | The ERC20 tokens to support                          |
| priceMultipliers    | uint256\[] | The price multiplier of each ERC20 token             |

### getTier

```solidity
function getTier(
    uint256 profileId, 
    uint256 tierSetId, 
    uint256 tierId, 
    address currency
) external view returns (string memory cid, uint256 price, bool deprecated)
```

Returns an existing tier

#### Parameters

| Name      | Type    | Description                                       |
| --------- | ------- | ------------------------------------------------- |
| profileId | uint256 | ID of the profile that owns the tier              |
| tierSetId | uint256 | ID of the tier set the tier is in                 |
| tierId    | uint256 | ID of the tier to return                          |
| currency  | address | ERC20 token contract address to price the tier in |

#### Return Values

| Name       | Type    | Description                         |
| ---------- | ------- | ----------------------------------- |
| cid        | string  | Returned CID of a tier              |
| price      | uint256 | Returned price of a tier            |
| deprecated | bool    | Returned deprecated state of a tier |

### getTierSet

```solidity
function getTierSet(
    uint256 profileId, 
    uint256 tierSetId
) external view returns (uint256[] memory prices, string[] memory cids, bool[] memory deprecated)
```

Returns an existing set of tiers

#### Parameters

| Name      | Type    | Description                              |
| --------- | ------- | ---------------------------------------- |
| profileId | uint256 | ID of the profile that owns the tier set |
| tierSetId | uint256 | ID if the tier set to return             |

#### Return Values

| Name       | Type       | Description                                          |
| ---------- | ---------- | ---------------------------------------------------- |
| prices     | uint256\[] | Returned base price of each tier in a tier set       |
| cids       | string\[]  | Returned CID of each tier in a tier set              |
| deprecated | bool\[]    | Returned deprecated state of each tier in a tier set |

### totalTiers

```solidity
function totalTiers(
    uint256 profileId, 
    uint256 tierSetId
) external view returns (uint256 total)
```

Returns the total number of tiers in a tier set

#### Parameters

| Name      | Type    | Description                                                   |
| --------- | ------- | ------------------------------------------------------------- |
| profileId | uint256 | ID of the profile that owns the tier set                      |
| tierSetId | uint256 | ID of the tier set to return the total number of tiers within |

#### Return Values

| Name  | Type    | Description                         |
| ----- | ------- | ----------------------------------- |
| total | uint256 | Number of total tiers in a tier set |

### totalTierSets

```solidity
function totalTierSets(
    uint256 profileId
) external view returns (uint256 total)
```

Returns the total number of tier sets owned by a profile

#### Parameters

| Name      | Type    | Description                                               |
| --------- | ------- | --------------------------------------------------------- |
| profileId | uint256 | ID of the profile to return the total number of tier sets |

#### Return Values

| Name  | Type    | Description                            |
| ----- | ------- | -------------------------------------- |
| total | uint256 | Number of total tier sets in a profile |

### getCurrencyMultiplier

```solidity
function getCurrencyMultiplier(
    uint256 profileId, 
    uint256 tierSetId, 
    address currency
) external view returns (uint256 multiplier)
```

Returns the currency multiplier of ERC20 token in a tier set

#### Parameters

| Name      | Type    | Description                                                    |
| --------- | ------- | -------------------------------------------------------------- |
| profileId | uint256 | ID of the profile that owns the tier set                       |
| tierSetId | uint256 | ID of the tier set                                             |
| currency  | address | ERC20 token contract address to return the currency multiplier |

#### Return Values

| Name       | Type    | Description                       |
| ---------- | ------- | --------------------------------- |
| multiplier | uint256 | Price multiplier of a ERC20 token |

### isCurrencySupported

```solidity
function isCurrencySupported(
    uint256 profileId, 
    uint256 tierSetId, 
    address currency
) external view returns (bool supported)
```

Returns true if a ERC20 token is supported by a tier set

#### Parameters

| Name      | Type    | Description                                                             |
| --------- | ------- | ----------------------------------------------------------------------- |
| profileId | uint256 | ID of the profile that owns the tier set                                |
| tierSetId | uint256 | ID of the tier set                                                      |
| currency  | address | ERC20 token contract address to return if it is supported by a tier set |

#### Return Values

| Name      | Type | Description                          |
| --------- | ---- | ------------------------------------ |
| supported | bool | Returns true if a ERC20 is supported |


---

# 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.backed.by/docs/developers/smart-contracts/core/bbtiers.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.
