# BBPosts

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

## Functions

### createPost

```solidity
function createPost(
    uint256 profileId, 
    string calldata cid
) external returns (uint256 postId)
```

Creates a post and sets its CID

#### Parameters

| Name      | Type    | Description                             |
| --------- | ------- | --------------------------------------- |
| profileId | uint256 | ID of the profile to create the post in |
| cid       | string  | CID of the created post                 |

#### Return Values

| Name   | Type    | Description            |
| ------ | ------- | ---------------------- |
| postId | uint256 | ID of the created post |

### editPost

```solidity
function editPost(
    uint256 profileId, 
    uint256 postId, 
    string calldata cid
) external
```

Sets an existing posts CID

#### Parameters

| Name      | Type    | Description                           |
| --------- | ------- | ------------------------------------- |
| profileId | uint256 | ID of the profile to edit the post in |
| postId    | uint256 | ID of the post to edit                |
| cid       | string  | New CID of the post                   |

### getPost

```solidity
function getPost(
    uint256 profileId, 
    uint256 postId
) external view returns (string memory cid)
```

Returns an existing posts CID

#### Parameters

| Name      | Type    | Description                          |
| --------- | ------- | ------------------------------------ |
| profileId | uint256 | ID of the profile that owns the post |
| postId    | uint256 | ID of the post to return             |

#### Return Values

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| cid  | string | Returned posts CID |

### profilesTotalPosts

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

Returns the number of total posts from a profile

#### Parameters

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

#### Return Values

| Name  | Type    | Description           |
| ----- | ------- | --------------------- |
| total | uint256 | Number of total posts |


---

# 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/bbposts.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.
