Closed olasunkanmi-SE closed 1 week ago
I like this a lot and think it is the general direction we should go.
Personally, I'm still grappling with Anchor design patterns so I'd prefer to start more simply. If everyone else is already comfortable with Anchor design, then we can ignore this and I'll play catchup.
If people want to take this route, I'd suggest we make a simple first iteration just to ensure it works, is at least modestly secure and we have basic frontend connectivity:
Fields:
authority
: Public key of the school administrator.enrollmentFee
: The cost to enroll in the school (in SOL or lamports).classRegistry
: A Vec of Strings indicating registered classesbookRegistry
: A Vec of Strings indicating class books .Fields:
studentId
: Unique identifier for the student (can be generated using a counter in the School account).studentNft
: The address of the student's ID NFT.enrolledClasses
: A list of class names the student is enrolled in.ownedBooks
: A list of book names the student owns.Inputs:
authority
: Public key of the student enrolling.payment
: Amount of SOL (or lamports) to pay the enrollment fee.Logic:
Verify the payment is sufficient. Mint a new student ID NFT and assign it to the student. Store the student's information (studentId, studentNft, student pubkey) in the School account. Transfer ownership of the NFT to the student.
Also, there were a few things I thought of here:
enrolledClasses
and ownedBooks
could be part of the NFT metadata, something which I understood to be more lightweight?Anyway, these are my first thoughts. I'd be able to allocate some time to this over the weekend if we like this direction so far.
School Account
Fields:
authority
: Public key of the school administrator.enrollmentFee
: The cost to enroll in the school (in SOL or lamports).classRegistry
: A mapping of class names to their NFT metadata.bookRegistry
: A mapping of book names to their NFT metadata.Student Account
Fields:
studentId
: Unique identifier for the student (can be generated using a counter in the School account).studentNft
: The address of the student's ID NFT.enrolledClasses
: A list of class names the student is enrolled in.ownedBooks
: A list of book names the student owns.Program Functions
enroll
Inputs:
authority
: Public key of the student enrolling.payment
: Amount of SOL (or lamports) to pay the enrollment fee.Logic:
studentId
,studentNft
) in the School account.registerClass
Inputs:
authority
: Public key of the student.className
: The name of the class to register for.Logic:
classRegistry
.enrolledClasses
list.requestBook
Inputs:
authority
: Public key of the student.bookName
: The name of the book to request.Logic:
bookRegistry
.updateClassRegistry
Inputs:
authority
: Public key of the school administrator.className
: Name of the class.classMetadata
: Metadata for the class (e.g., description, teacher, schedule).Logic:
classRegistry
.updateBookRegistry
Inputs:
authority
: Public key of the school administrator.bookName
: Name of the book.bookMetadata
: Metadata for the book (e.g., title, author, subject).Logic:
bookRegistry
.