AlphaPING Smart Contract Documentation
Overview
The AlphaPING
smart contract is a decentralized platform built on Arbitrum where users can mint NFT memberships, join or create channels, manage memberships, interact with ERC20/ERC721 tokens, and handle user profiles and privacy settings. This contract supports features like premium subscriptions, user bans, personal blocking/following, and channel moderation.
Key Features
- Minting and managing membership via NFTs.
- Channel creation with ERC20/ERC721 token-based memberships.
- Profile management (username and profile picture).
- Premium membership system with subscription payments.
- Moderation tools (ban users, transfer mod ownership).
- Personal privacy settings (block and follow users).
- Blacklist functionality for malicious behavior.
Contract Structure
The contract consists of several components and mappings to manage users, channels, and subscriptions.
State Variables
totalSupply
: Tracks the total supply of NFTs minted (used for membership).owner
: The address of the contract owner.mods
: Mapping of channel IDs to moderators.totalChannels
: Tracks the number of channels created.channelExistsForToken
: Mapping to track whether a channel has been created for a specific token address.channels
: Mapping of channel IDs to channel details (token address, token type, etc.).hasJoinedChannel
: Tracks whether an address has joined a specific channel.isMember
: Maps user addresses to membership status.profilePic
: Stores the profile picture URL string for each user.username
: Maps users to their chosen usernames.isBlackListed
: Tracks blacklisted users (those banned from the platform).channelBans
: Mapping to track bans per channel.promoPeriod
: Flag for a promotional period (can be toggled).premiumMembershipExpiry
: Mapping to track the expiry date of premium memberships for users.monthDuration
: The duration (in seconds) of a monthly subscription.subscriptionPriceMonthly
: The cost (in the subscription currency) for a monthly subscription.subscriptionCurrency
: The address of the ERC20 token used for subscriptions.personalBlockList
: Mapping of user addresses to addresses they have blocked.personalFollowList
: Mapping of user addresses to addresses they are following.
Structs
Channel
struct Channel { uint256 id; address tokenAddress; string name; string tokenType; }
id
: The unique identifier for each channel.tokenAddress
: The address of the ERC20/ERC721 token associated with the channel.name
: The name of the channel.tokenType
: The type of token used (either "ERC20" or "ERC721").
Modifiers
onlyOwner
: Restricts access to the contract's owner.onlyMod
: Restricts access to channel moderators and the owner.onlyMember
: Restricts access to users who hold a membership NFT.onlyGoodOnes
: Restricts access to non-blacklisted users.onlyLegitChannels
: Ensures the channel ID is valid.
Functions
Minting and Membership
mint()
Allows users to mint a new membership NFT and join the platform as a member.
function mint() public;
Profile Management
setProfilePic(string memory _picString)
Allows users to set their profile picture as a string (URL). Must be an image filetype (.png, .jpg, etc)
function setProfilePic(string memory _picString) public;
setUsername(string memory _username)
Allows users to set their username.
function setUsername(string memory _username) public;
Channel Management
createChannel(address _tokenAddress, string memory _tokenType)
Allows a member to create a new channel using an ERC20/ERC721 token. The token type must be specified.
function createChannel(address _tokenAddress, string memory _tokenType) public onlyMember onlyGoodOnes;
joinChannel(uint _channelId)
Allows a member to join a channel.
function joinChannel(uint _channelId) public onlyMember onlyLegitChannels;
leaveChannel(uint _channelId)
Allows a member to leave a channel.
function leaveChannel(uint _channelId) public onlyLegitChannels;
getChannel(uint _channelId)
Returns the details of a specific channel.
function getChannel(uint _channelId) public view onlyLegitChannels returns (Channel memory);
Ownership and Moderation
transferOwner(address _newOwner)
Transfers the ownership of the contract to a new address.
function transferOwner(address _newOwner) public onlyOwner;
transferMod(address _newMod, uint256 _channelId)
Transfers the moderator role of a specific channel to a new address.
function transferMod(address _newMod, uint256 _channelId) public onlyMod(_channelId);
channelBan(address _bannedAccount, uint256 _channelId)
Bans a user from a specific channel.
function channelBan(address _bannedAccount, uint256 _channelId) public onlyMod(_channelId);
channelUnban(address _bannedAccount, uint256 _channelId)
Unbans a user from a specific channel.
function channelUnban(address _bannedAccount, uint256 _channelId) public onlyMod(_channelId);
User Blacklist and Ban Management
blacklistUser(address _blacklistedUser)
Blacklists a user from the entire platform.
function blacklistUser(address _blacklistedUser) public onlyOwner;
unBlacklistUser(address _blacklistedUser)
Removes a user from the blacklist.
function unBlacklistUser(address _blacklistedUser) public onlyOwner;
banMod(address _bannedMod, uint256[] memory _channelIds)
Bans a moderator from the platform and transfers their mod role to the owner for the specified channels.
function banMod(address _bannedMod, uint256[] memory _channelIds) public onlyOwner;
Personal Blocklist and Follow List
addToPersonalBlockList(address _blacklistedAddress)
Adds a user to the caller’s personal blocklist.
function addToPersonalBlockList(address _blacklistedAddress) public;
removeFromPersonalBlockList(address _blacklistedAddress)
Removes a user from the caller’s personal blocklist.
function removeFromPersonalBlockList(address _blacklistedAddress) public;
addToPersonalFollowList(address _followedAddress)
Adds a user to the caller’s personal follow list.
function addToPersonalFollowList(address _followedAddress) public;
removeFromPersonalFollowList(address _followedAddress)
Removes a user from the caller’s personal follow list.
function removeFromPersonalFollowList(address _followedAddress) public;
Subscription and Premium Membership
setSubscriptionPriceMonthly(uint256 _price)
Sets the monthly subscription price for premium membership.
function setSubscriptionPriceMonthly(uint256 _price) public onlyOwner;
setSubscriptionCurrency(address _currencyAddress)
Sets the address of the ERC20 token used for subscription payments.
function setSubscriptionCurrency(address _currencyAddress) public onlyOwner;
Example Use Cases
Minting a Membership:
Users mint an NFT, which grants them access to the platform and its features (like creating or joining channels).
Creating a Channel:
A member creates a channel using an ERC20/ERC721 token. The channel will be associated with that token.
Joining/Leaving a Channel:
A member joins or leaves a channel at any time, allowing them to participate in token-based activities.
Moderation:
Moderators can ban or unban users from specific channels, while the contract owner can manage the overall platform by blacklisting users or transferring ownership.