Skip to content

Feat: Implement payment functions into ChainEvents contract with tests#197

Open
emarc99 wants to merge 7 commits intomubarak23:developfrom
emarc99:feat-payment
Open

Feat: Implement payment functions into ChainEvents contract with tests#197
emarc99 wants to merge 7 commits intomubarak23:developfrom
emarc99:feat-payment

Conversation

@emarc99
Copy link
Copy Markdown

@emarc99 emarc99 commented Jun 19, 2025

Key implementation details:

  1. Payment Validation:

    • Checks that the event exists and is of paid type
    • Verifies the event isn't closed
    • Ensures the user hasn't already paid for this event
    • Ensures that users registered for an event before paying for it
  2. Payment Tracking:

    • Stores payment details in paid_events mapping (user → (event_id, amount))
    • Tracks total amount collected per event in paid_events_amount
    • Counts tickets sold in paid_event_ticket_count
  3. Withdrawal Security:

    • Only event owner can withdraw
    • Checks there are funds to withdraw
    • Resets balance before transfer to prevent reentrancy
    • Uses openzeppelin ERC20 transfer_from call
  4. Events:

    • Added PaymentMade and PaymentWithdrawn events
    • Emitted when payments are made or withdrawn
  5. Additional Functions:

  • Implemented fetch_user_paid_event() to return user's payment info

@emarc99 emarc99 changed the base branch from main to develop June 19, 2025 22:53
@emarc99
Copy link
Copy Markdown
Author

emarc99 commented Jun 19, 2025

@mubarak23 kindly lemme know if something is amiss, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Payment Functionality for Paid Events

1 participant