UserFactory Contract

The UserFactory contract is responsible for managing user profiles and creators on Thetafans. It provides functions for creating user profiles, associating creators with their profiles, and collecting subscription fees. Let's explore the key components and functions of the UserFactory contract:

Contract Overview

  • Name: UserFactory

  • Responsibility: User profile and creator management

  • Status: Active

Contract Variables

  • createdProfiles: An array of addresses representing the created user profiles.

  • userProfile: A mapping that associates the profile name with its corresponding address.

  • creatorContract: A mapping that links a creator's address with their profile's address.

  • admin: The address of the contract administrator.

  • subscriptionFee: The percentage of the subscription fee charged by Thetafans.

  • amountRecaudedFees: The total amount of subscription fees collected.

Contract Functions

  • createProfile(string memory _tokenName, string memory _tokenSymbol, string memory _name, string memory _description, uint _bronzePrice, uint _silverPrice, uint _goldPrice): Creates a new user profile for a content creator.

  • isSignedUp(address _creatorAddress) external view returns(bool): Checks if a creator has signed up and created a profile.

  • recaudeFees() external payable: Collects the subscription fees and records the amount.

  • withdrawFees(address payable _to) public: Allows the contract administrator to withdraw the collected subscription fees.

  • getCreatorContractAddress(address _creatorAddress) external view returns(address): Retrieves the address of the creator's profile contract.

  • getAllCreators() public view returns(address[] memory): Retrieves an array of addresses representing all created user profiles.

Usage Example

Creating a User Profile

To create a user profile for a content creator, use the createProfile function:

solidityCopy codefunction createProfile(
    string memory _tokenName,
    string memory _tokenSymbol,
    string memory _name,
    string memory _description,
    uint _bronzePrice,
    uint _silverPrice,
    uint _goldPrice
) public
  • _tokenName: The name of the ERC721 token representing the user profile.

  • _tokenSymbol: The symbol of the ERC721 token.

  • _name: The name of the user profile.

  • _description: A description of the user profile.

  • _bronzePrice: The subscription fee for the bronze tier.

  • _silverPrice: The subscription fee for the silver tier.

  • _goldPrice: The subscription fee for the gold tier.

This function creates a new user profile for the content creator and associates it with their address.

Retrieving Creator Information

To retrieve information about a creator, use the following functions:

  • isSignedUp(address _creatorAddress) external view returns(bool): Checks if a creator has signed up and created a profile.

  • getCreatorContractAddress(address _creatorAddress) external view returns(address): Retrieves the address of the creator's profile contract.

  • getAllCreators() public view returns(address[] memory): Retrieves an array of addresses representing all created user profiles.

These functions provide convenient ways to obtain information about creators and their associated user profiles.

Last updated