Skip to content

plasa-labs/plasa-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plasa Protocol

Plasa Protocol is a decentralized platform that implements a unique system of Stamps, Points, and Questions for community engagement and governance. This README provides an overview of the main components and their functionalities.

Table of Contents

Protocol

Plasa Protocol is a decentralized platform that implements a unique system of Stamps, Points, and Questions for community engagement and governance.

Spaces

Spaces represent communities, organizations, or leaders using Plasa for their community engagement and governance. Each Space manages its own follower stamps, points, and questions.

Key features:

  • Deploys and manages Follower Since Stamps and Follower Since Points
  • Creates and manages Fixed and Open Questions
  • Customizable space information (name, description, image URL)

Space Components

  • Stamps: Represents a user's follower status since a specific date on a platform.
  • Points: Calculates points based on how long a user has been a follower.
  • Questions: Both Fixed and Open questions for community voting and governance.

Stamps

Stamps are non-transferable ERC721 tokens that represent specific achievements or statuses within the Plasa ecosystem. There are two types of stamps:

Account Ownership Stamp

  • Represents ownership of an account on a specific platform (e.g., Twitter, GitHub).
  • Each stamp is unique to a platform and username combination.
  • Minting requires a signature from an authorized signer.

Key features:

  • Platform-specific (e.g., "Twitter", "GitHub")
  • Username-to-stampId mapping
  • Signature-based minting

Follower Since Stamp

  • Represents a user's follower status since a specific date on a platform.
  • Each stamp includes a timestamp indicating when the follow relationship began.
  • Useful for calculating duration-based points.

Key features:

  • Platform and followed account specific
  • Stores the follow start timestamp for each stamp
  • Signature-based minting

Points

Points are non-transferable ERC20-like tokens that represent a user's influence or participation within the Plasa ecosystem. There are two types of point systems:

Follower Since Points

  • Calculates points based on how long a user has been a follower.
  • Uses the Follower Since Stamp to determine the duration of following.
  • Points increase over time as long as the user remains a follower.

Key features:

  • Time-based point calculation
  • Integrates with Follower Since Stamp
  • Non-transferable

Multiple Follower Since Points

  • An extension of Follower Since Points that considers multiple follower relationships.
  • Allows for different point multipliers for various platforms or followed accounts.
  • Aggregates points from multiple Follower Since Stamps.

Key features:

  • Supports multiple follower relationships
  • Configurable point multipliers for each relationship
  • Aggregates points across platforms or followed accounts

Questions

Questions are the core of the Plasa governance system, allowing users to create and vote on proposals. There are two types of questions:

Fixed Question

  • Has a predefined set of options that cannot be changed after creation.
  • Users can only vote on the existing options.

Key features:

  • Immutable options
  • Voting based on user's point balance

Open Question

  • Allows users to add new options during the voting period.
  • Requires a minimum point balance to add a new option.

Key features:

  • Dynamic option addition
  • Minimum point requirement for adding options
  • Voting based on user's point balance

Smart Contracts

The Plasa Protocol is implemented using several Solidity smart contracts:

  1. Space.sol: Main contract for managing a space, including follower stamps, points, and questions.
  2. Stamp.sol: Base contract for non-transferable ERC721 tokens (stamps).
  3. AccountOwnershipStamp.sol: Implementation of the Account Ownership Stamp.
  4. FollowerSinceStamp.sol: Implementation of the Follower Since Stamp.
  5. Points.sol: Base contract for non-transferable ERC20-like tokens (points).
  6. FollowerSincePoints.sol: Implementation of the Follower Since Points system.
  7. MultipleFollowerSincePoints.sol: Implementation of the Multiple Follower Since Points system.
  8. Question.sol: Base contract for voting questions.
  9. OpenQuestion.sol: Implementation of the Open Question type.
  10. FixedQuestion.sol: Implementation of the Fixed Question type.

These contracts work together to create a comprehensive system for community engagement, reputation tracking, and decentralized decision-making.

For detailed information on each contract and its functions, please refer to the inline documentation in the source code.

Queries

The Plasa Protocol provides various ways to query data from the smart contracts. Here are some common queries and how to perform them:

Spaces

Each space contract has a getSpaceView() function that returns a SpaceView struct. This struct contains all the information about the space.

/// @notice Gets a comprehensive view of the space for a given user
/// @param user The address of the user to get the view for
/// @return A SpaceView struct containing all relevant information about the space
function getSpaceView(address user) external view returns (SpaceView memory);

/// @notice Represents a comprehensive view of a space
struct SpaceView {
string name;
string description;
string imageUrl;
address owner;
StampView stamp;
PointsView points;
QuestionPreview[] questions;
}
/// @notice Represents a view of the follower stamp associated with the space
struct StampView {
address addr;
string platform;
string followedAccount;
bool userHasStamp;
}
/// @notice Represents a view of the points system associated with the space
struct PointsView {
address addr;
uint256 userCurrentBalance;
}
/// @notice Represents a preview of a question in the space
struct QuestionPreview {
address addr;
string title;
string description;
uint256 deadline;
bool isActive;
bool userHasVoted;
}

Questions

Each question contract has a getQuestionView(address user) function that returns a QuestionView struct. This struct contains all the information about the question and the user's voting status. It includes an array of OptionView structs, which contain information about each option.

/// @notice Get a comprehensive view of the question for a specific user
/// @param user The address of the user to get the view for
/// @return A QuestionView struct with all question details
function getQuestionView(address user) external view returns (QuestionView memory);

/// @dev Represents a comprehensive view of a question with all its details
struct QuestionView {
QuestionType questionType; // The type of question (Fixed or Open), set in the constructor of OpenQuestion or FixedQuestion
string title; // The title of the question, can be updated with Question.updateTitle()
string description; // The description of the question, can be updated with Question.updateDescription()
uint256 deadline; // The voting deadline, can be updated with Question.updateDeadline()
uint256 totalVoteCount; // The total number of votes across all options, calculated in Question.getQuestionView()
OptionView[] options; // Array of all voting options with their details, populated in Question.getQuestionView()
bool isActive; // Whether the question is currently active, determined by Question.isActive()
address owner; // The owner of the question contract, set in the constructor and managed by Ownable
uint256 started; // The timestamp when the question was deployed, set in the Question constructor
uint256 userOptionVoted; // The option ID the user voted for (0 if not voted), set in Question.getQuestionView()
uint256 userPointsCurrent; // The user's current point balance, retrieved from the Points contract
uint256 userPointsDeadline; // The user's point balance at the voting deadline, retrieved from the Points contract
bool userCanAddOption; // Whether the user can add a new option (always false for FixedQuestion, conditional for OpenQuestion)
}

/// @dev Represents a view of a voting option with additional user-specific data
struct OptionView {
string title; // The title of the option, set in Question._addOption()
string description; // The description of the option, set in Question._addOption()
address proposer; // The address that proposed this option, set to msg.sender in Question._addOption()
uint256 voteCount; // The total number of votes for this option, incremented in Question.vote()
uint256 pointsAccrued; // Total points accrued for this option, updated in Question.vote()
bool userVoted; // Whether the specific user voted for this option, checked in Question.getQuestionView()
}

/// @dev Defines the type of question
enum QuestionType {
Null,
Fixed,
Open
}

More details can be found in the IQuestion.sol interface.

Write

FollowerSinceStamp

mintStamp

/// @notice Mints a new follower since stamp
/// @dev This function verifies the signature, mints a new stamp, and prevents duplicate minting
/// @param follower The identifier of the follower on the platform
/// @param since The timestamp since when the user has been following
/// @param deadline The timestamp after which the signature is no longer valid
/// @param signature The signature authorizing the minting, signed by a trusted authority
/// @return stampId The ID of the newly minted stamp
function mintStamp(
string calldata follower,
uint256 since,
uint256 deadline,
bytes calldata signature
) external returns (uint256 stampId);

Questions

vote

// External functions
/// @notice Cast a vote for an option
/// @param optionId The ID of the option to vote for
function vote(uint256 optionId) external;

addOption (OpenQuestion only)

/// @notice Adds a new option to the question
/// @dev Requires the caller to have sufficient points
/// @param _title The title of the new option
/// @param _description The description of the new option
function addOption(string memory _title, string memory _description) external;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published