Skip to content

feat: implement escrow payment func#1

Open
mxllv wants to merge 1 commit intomainfrom
feat/escrow
Open

feat: implement escrow payment func#1
mxllv wants to merge 1 commit intomainfrom
feat/escrow

Conversation

@mxllv
Copy link
Owner

@mxllv mxllv commented Mar 31, 2025

Description:
This pull request introduces a secure payment escrow system in the contract, allowing users to lock funds until predefined conditions are met. The system includes functionalities for creating, releasing, and refunding escrowed payments, providing an additional layer of security and trust for transactions between a sender and a receiver.

Closes Lead-Studios#6

Changes:

  1. Escrow Contract Implementation:

    • Introduced a new contract EscrowContract with methods for creating, releasing, and refunding escrow payments.
  2. EscrowInfo Struct:

-The EscrowInfo struct holds information about each escrow, including:
- sender: The address of the sender.
- receiver: The address of the receiver.
- amount: The escrow amount.
- condition: The condition that must be met for the funds to be released.
- released: A boolean indicating whether the funds have been released.
- refunded: A boolean indicating whether the funds have been refunded.

  1. Functions:

    • create(): Allows the sender to lock funds into the escrow account.
    • Verifies sender balance before transferring the amount to the contract.
    • Stores the escrow information, including the condition and the amount.
    • release(): Releases the funds to the receiver if conditions are met (currently includes a basic time-based condition).
    • Verifies that the escrow has not been previously released or refunded.
    • Transfers the amount to the receiver and updates the escrow status.
    • refund(): Allows the sender to refund the escrowed funds if conditions are not met.
    • Verifies that the escrow has not been released or refunded and requires sender authorization before refunding.
    • get_escrow(): Retrieves the current status of an escrow based on the escrow ID.
4. Storage and Validation:
  
  - Utilizes a persistent storage mechanism to track the state of each escrow, including the escrow ID, amount, condition,
     and status (released/refunded).
  -  Escrow count is incremented with each new escrow creation to ensure unique IDs.

The contract successfully handles various scenarios such as insufficient balance, double-release, and unauthorized refunds.

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.

Develop Secure Payment Escrow System in Rust

2 participants