Skip to main content

Solidity API

ExceedsMaxVotePerUser

error ExceedsMaxVotePerUser()
Custom errors for the POP contract

InsufficientVotedAmount

error InsufficientVotedAmount()

TokensStillLocked

error TokensStillLocked()

NoTokensToWithdraw

error NoTokensToWithdraw()

InvalidAddress

error InvalidAddress()

Contract: POP

voteOnAttestation

function voteOnAttestationfunction voteOnAttestation(bytes32 attestationUID, uint256 amount) external
Allows users to vote on an attestation to increase its popularity

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation
amountThe amount of tokens to vote with

requestVoteWithdrawal

function requestVoteWithdrawalfunction requestVoteWithdrawal(bytes32 attestationUID, uint256 amount) external
Allows users to request withdrawal of their votes

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation
amountThe amount of tokens to withdraw

withdrawVotes

function withdrawVotesfunction withdrawVotes(bytes32 attestationUID) external
Allows users to withdraw their tokens after timelock period

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation

getPopularityScore

function getPopularityScorefunction getPopularityScore(bytes32 attestationUID) external view returns (uint256)
Returns the popularity score of an attestation

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation

Return Values

Description
The popularity score

getUserVotedAmount

function getUserVotedAmountfunction getUserVotedAmount(bytes32 attestationUID, address user) external view returns (uint256)
Returns the amount of tokens voted by a user for an attestation

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation
userThe address of the user

Return Values

Description
The amount of tokens voted

getTotalVotedAmount

function getTotalVotedAmountfunction getTotalVotedAmount(bytes32 attestationUID) external view returns (uint256)
Returns the total amount of tokens voted for an attestation

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation

Return Values

Description
The total amount of tokens voted

getUnlockTime

function getUnlockTimefunction getUnlockTime(bytes32 attestationUID, address user) external view returns (uint256)
Returns the unlock time for a user’s voted tokens

Parameters

NameDescription
attestationUIDThe unique identifier of the attestation
userThe address of the user

Return Values

Description
The unlock time as a Unix timestamp

setMaxVotePerUser

function setMaxVotePerUserfunction setMaxVotePerUser(uint256 _maxVotePerUser) external
Updates the maximum vote per user

Parameters

NameDescription
_maxVotePerUserThe new maximum vote per user
Dev: Only callable by the contract owner

setCASAddress

function setCASAddressfunction setCASAddress(address _casAddress) external
Updates the CAS contract address

Parameters

NameDescription
_casAddressThe new CAS contract address
Dev: Only callable by the contract owner

getTopAttestations

function getTopAttestationsfunction getTopAttestations(uint256 count) external view returns (bytes32[])
Get top N most popular attestations

Parameters

NameDescription
countThe number of attestations to return

Return Values

Description
An array of attestation UIDs sorted by popularity

getTopAttestationsWithScores

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

function withdrawVoteTokenfunction withdrawVoteToken(uint256 amount) external
Withdraws specified amount of vote tokens from the contract

Parameters

NameDescription
amountThe amount of vote tokens to withdraw
Dev: Only callable by the contract owner

Public Functions

constructor

function constructorconstructor() public

initialize

function initializefunction initialize(address initialOwner, address voteToken, address _casAddress, uint256 _maxVotePerUser) public
Initializes the POP contract with required parameters

Parameters

NameDescription
initialOwnerThe address that will own the contract
voteTokenThe address of the ERC20 token used for voting (same as CAS bond token)
_casAddressThe address of the CAS contract
_maxVotePerUserMaximum vote amount per user per attestation

Events

TokensVoted

event TokensVotedevent TokensVoted(bytes32 attestationUID, address user, uint256 amount)

WithdrawalRequested

event WithdrawalRequestedevent WithdrawalRequested(bytes32 attestationUID, address user, uint256 amount, uint256 unlockTime)

TokensWithdrawn

event TokensWithdrawnevent TokensWithdrawn(bytes32 attestationUID, address user, uint256 amount)

TopAttestationsUpdated

event TopAttestationsUpdatedevent TopAttestationsUpdated(bytes32[3] topAttestations, uint256[3] topScores)