Skip to content

[CourseRegistry] Trigger payout on course completion #53

@Kaylahray

Description

@Kaylahray

Description

A cross-contract call from the CourseRegistry to the RewardPool. When a learner marks their final module as complete, the contract calls distribute_reward on the RewardPool so learners are instantly compensated without manual intervention.

User Story

As the Learnault Protocol,
I want to automatically trigger a USDC reward when a learner finishes a course,
so that learners are instantly compensated for their educational progress without manual intervention.

Requirements and Context

  • Files: contracts/course-registry/src/lib.rs, contracts/course-registry/src/test.rs
  • After incrementing a learner's progress, check if progress == total_modules
  • If true, initialize RewardPoolClient and call distribute_reward with the predefined course payout amount

Suggested Implementation

// IN FUNCTION: complete_module(env: Env, learner: Address, course_id: u32)
// 1. // ... progress increment logic ...
// 2. if new_progress == course.total_modules {
// 3.     let reward_pool = RewardPoolClient::new(&env, &reward_pool_address);
// 4.     let base_reward = 10_0000000; // e.g., 10 USDC
// 5.     reward_pool.distribute_reward(&env.current_contract_address(), &learner, &base_reward);
// 6.     emit CourseCompleted event.
// 7. }

Acceptance Criteria

  • USDC is transferred to the learner upon finishing the last module.
  • Fails if the CourseRegistry is not whitelisted in the RewardPool.

Submission Guidelines

  • Branch: feat/course-completion-payout
  • Depends on: RewardPool distribute_reward function
  • PR: feat(course-registry): trigger USDC payout on course completion

Metadata

Metadata

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions