Skip to content

Request SDK - Double Payment Prevention - Implement a Nonce or Idempotency Key at smart contract level #1626

@MantisClone

Description

@MantisClone

Problem

The payment proxy smart contracts will process an accidental "double payment" in which the user submits the same transaction twice.

Proposed Solution

  • Sequential nonce
    • Smart contract registry of nonces for each payment reference
    • New payment proxy smart contracts that check the registry before processing payments.
    • When creating a request, register the payment reference with nonce 0 on the registry on the payment chain.
    • When paying a request, caller includes the next nonce. Smart contract checks that the nonce is correct.

Details: Brainstorm in the double payment prevention feature

Considerations

  • How to handle "In-Memory Requests" (Pay-before-persist)?

    • Proposed: If paymentReference not in registry, skip nonce check. In other words, "In-memory Requests" don't get double payment prevention.
  • This solution would not prevent "overpayment" where the user submits a correct nonce, but the amount exceeds the expected amount of the request. This is intentional because overpayment prevention is more complicated to implement. It would require storing the expected amount onchain and crosschain messaging to make it available on the payment chain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    🎫 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions