The "Peace Antz Academy" contract is a factory contract that facilitates the creation of new course contracts on any EVM-compatible chain. It maintains rankings and statistics for teachers, students, and sponsors, and updates these values based on events such as course enrolment, course completion, and sponsorship. The contract ensures the validity of these operations by checking if the calling contract is a recognized course contract. Overall, it serves as the central hub for managing courses and tracking participants' activities in the Peace Antz Academy.
The Peace Antz Academy Contract, also known as the CourseFactory contract, is a factory contract written in Solidity for deploying individual course contracts on any EVM-compatible blockchain. It also maintains ranking and statistical data for teachers, students, and sponsors in the Peace Antz Academy system.
Course Creation: Teachers can deploy a new course contract using the createCourse()
function, with the teacher's address automatically assigned.
Ranking and Statistics: The contract maintains three types of rank structures: TeacherRank
, StudentRank
, and SponsorRank
. Each structure holds relevant statistics for teachers, students, and sponsors respectively, such as total earned for teachers, total staked for students, and total sponsored for sponsors.
Academy Information: The AcademyInfo
structure records academy-wide statistics, including total value locked (TVL), total sponsored, total staked, total payouts, and a "fail fund".
Course Contract Verification: The isValid()
modifier is used to ensure that functions are only called by recognized course contracts.
Updates for Course Events: Various functions are provided to update rankings and academy information based on course-related events. For example, updateStudentStake()
is called when a student enrolls in a course, updateStudentCourses()
is called when a student passes a course, updateBoot()
is called when a student is removed from a course, and updatePaymentRank()
is called when a course ends and payments are distributed.
Sponsorship Management: Functions are available for updating sponsor-related information, such as when a sponsor begins sponsoring a course (updateSponsorsProgress()
), when a new sponsorship is created (updateSponsorship()
), and when a sponsorship is ended (updateUnsponsor()
).
To interact with the contract, users should first deploy it on the desired network. Teachers can create new courses, and students and sponsors can interact with these courses according to their roles. Course contracts can then call functions in the factory contract to update rankings and academy information based on course progress and outcomes.
The contract emits an CourseCreated
event when a new course is created, which can be useful for front-end applications to track new courses.
This contract leverages access control in the individual course contracts to maintain security. Therefore, it's crucial to ensure the security of individual course contracts, as they have significant permissions in the factory contract. The isValid()
modifier in the factory contract ensures that functions are only called by recognized course contracts.
Updated sponsorship function so it only adds one course if the user sponsors the same course multiple times.
Dec 26, 2023
MIT, Apache-2.0