> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cultura.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# POP

# Solidity API

## ExceedsMaxVotePerUser

```solidity theme={null}
error ExceedsMaxVotePerUser()
```

Custom errors for the POP contract

## InsufficientVotedAmount

```solidity theme={null}
error InsufficientVotedAmount()
```

## TokensStillLocked

```solidity theme={null}
error TokensStillLocked()
```

## NoTokensToWithdraw

```solidity theme={null}
error NoTokensToWithdraw()
```

## InvalidAddress

```solidity theme={null}
error InvalidAddress()
```

# Contract: POP

### voteOnAttestation

```solidity theme={null}
function voteOnAttestationfunction voteOnAttestation(bytes32 attestationUID, uint256 amount) external
```

Allows users to vote on an attestation to increase its popularity

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |
| `amount`         | The amount of tokens to vote with        |

### requestVoteWithdrawal

```solidity theme={null}
function requestVoteWithdrawalfunction requestVoteWithdrawal(bytes32 attestationUID, uint256 amount) external
```

Allows users to request withdrawal of their votes

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |
| `amount`         | The amount of tokens to withdraw         |

### withdrawVotes

```solidity theme={null}
function withdrawVotesfunction withdrawVotes(bytes32 attestationUID) external
```

Allows users to withdraw their tokens after timelock period

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |

### getPopularityScore

```solidity theme={null}
function getPopularityScorefunction getPopularityScore(bytes32 attestationUID) external view returns (uint256)
```

Returns the popularity score of an attestation

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |

#### Return Values

| Description          |
| -------------------- |
| The popularity score |

### getUserVotedAmount

```solidity theme={null}
function getUserVotedAmountfunction getUserVotedAmount(bytes32 attestationUID, address user) external view returns (uint256)
```

Returns the amount of tokens voted by a user for an attestation

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |
| `user`           | The address of the user                  |

#### Return Values

| Description                |
| -------------------------- |
| The amount of tokens voted |

### getTotalVotedAmount

```solidity theme={null}
function getTotalVotedAmountfunction getTotalVotedAmount(bytes32 attestationUID) external view returns (uint256)
```

Returns the total amount of tokens voted for an attestation

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |

#### Return Values

| Description                      |
| -------------------------------- |
| The total amount of tokens voted |

### getUnlockTime

```solidity theme={null}
function getUnlockTimefunction getUnlockTime(bytes32 attestationUID, address user) external view returns (uint256)
```

Returns the unlock time for a user's voted tokens

#### Parameters

| Name             | Description                              |
| ---------------- | ---------------------------------------- |
| `attestationUID` | The unique identifier of the attestation |
| `user`           | The address of the user                  |

#### Return Values

| Description                         |
| ----------------------------------- |
| The unlock time as a Unix timestamp |

### setMaxVotePerUser

```solidity theme={null}
function setMaxVotePerUserfunction setMaxVotePerUser(uint256 _maxVotePerUser) external
```

Updates the maximum vote per user

#### Parameters

| Name              | Description                   |
| ----------------- | ----------------------------- |
| `_maxVotePerUser` | The new maximum vote per user |

*Dev:* Only callable by the contract owner

### setCASAddress

```solidity theme={null}
function setCASAddressfunction setCASAddress(address _casAddress) external
```

Updates the CAS contract address

#### Parameters

| Name          | Description                  |
| ------------- | ---------------------------- |
| `_casAddress` | The new CAS contract address |

*Dev:* Only callable by the contract owner

### getTopAttestations

```solidity theme={null}
function getTopAttestationsfunction getTopAttestations(uint256 count) external view returns (bytes32[])
```

Get top N most popular attestations

#### Parameters

| Name    | Description                          |
| ------- | ------------------------------------ |
| `count` | The number of attestations to return |

#### Return Values

| Description                                       |
| ------------------------------------------------- |
| An array of attestation UIDs sorted by popularity |

### getTopAttestationsWithScores

```solidity theme={null}
function getTopAttestationsWithScoresfunction getTopAttestationsWithScores() external view returns (bytes32[3] attestations, uint256[3] scores)
```

Get the top 3 attestations and their scores

#### Return Values

| Description                                    |
| ---------------------------------------------- |
| Array of the top 3 attestation UIDs            |
| Array of the scores for the top 3 attestations |

### withdrawVoteToken

```solidity theme={null}
function withdrawVoteTokenfunction withdrawVoteToken(uint256 amount) external
```

Withdraws specified amount of vote tokens from the contract

#### Parameters

| Name     | Description                           |
| -------- | ------------------------------------- |
| `amount` | The amount of vote tokens to withdraw |

*Dev:* Only callable by the contract owner

## Public Functions

### constructor

```solidity theme={null}
function constructorconstructor() public
```

### initialize

```solidity theme={null}
function initializefunction initialize(address initialOwner, address voteToken, address _casAddress, uint256 _maxVotePerUser) public
```

Initializes the POP contract with required parameters

#### Parameters

| Name              | Description                                                             |
| ----------------- | ----------------------------------------------------------------------- |
| `initialOwner`    | The address that will own the contract                                  |
| `voteToken`       | The address of the ERC20 token used for voting (same as CAS bond token) |
| `_casAddress`     | The address of the CAS contract                                         |
| `_maxVotePerUser` | Maximum vote amount per user per attestation                            |

## Events

### `TokensVoted`

```solidity theme={null}
event TokensVotedevent TokensVoted(bytes32 attestationUID, address user, uint256 amount)
```

### `WithdrawalRequested`

```solidity theme={null}
event WithdrawalRequestedevent WithdrawalRequested(bytes32 attestationUID, address user, uint256 amount, uint256 unlockTime)
```

### `TokensWithdrawn`

```solidity theme={null}
event TokensWithdrawnevent TokensWithdrawn(bytes32 attestationUID, address user, uint256 amount)
```

### `TopAttestationsUpdated`

```solidity theme={null}
event TopAttestationsUpdatedevent TopAttestationsUpdated(bytes32[3] topAttestations, uint256[3] topScores)
```
