Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.86 KB

File metadata and controls

47 lines (38 loc) · 1.86 KB

Withdrawal System

The system supports multi-channel withdrawals, allowing users to move their earned tokens to external wallets.

💸 Supported Gateways

1. FaucetPay (Micro-Payments)

  • Use Case: Small amounts, low fees, instant settlement off-chain.
  • Identifier: Email Address.
  • Integration: Uses the FaucetPay Merchant API.
  • Minimum: Dynamic (e.g., 0.000001 BTC).

2. CoinPayments (Direct Blockchain)

  • Use Case: Larger amounts, direct to wallet.
  • Identifier: Wallet Address (e.g., BTC, LTC, DOGE).
  • Integration:
    • API: create_withdrawal
    • Security: HMAC-SHA512 Request Signing.
    • Auto Confirm: Configured to 1 (System requests processing immediately), but actual broadcast depends on CoinPayments funds.
  • Minimum: Dynamic (e.g., 0.0002 BTC) due to network fees.

⚙️ Workflow

  1. Request:

    • User selects Coin + Gateway.
    • System validates:
      • Balance sufficient?
      • Address valid?
      • Amount >= Minimum?
    • Deducts balance immediately.
    • Creates transaction record (Status: pending).
  2. Approval (Admin Control):

    • Admins view Pending Withdrawals.
    • Action: Approve:
      • System calls the respective Gateway API.
      • On success: Status -> completed, TX Hash recorded.
      • On failure: Admin sees error (User not refunded automatically to allow retry/manual fix, or manual refund via Reject).
    • Action: Reject:
      • System refunds the tokens to the user.
      • Status -> rejected.

🛠️ Implementation

  • Backend: lib/services/faucetpay.ts, lib/services/coinpayments.ts
  • Actions: app/api/wallets/withdraw/actions.ts
  • Database: transactions, coin_gateways (stores limits/fees).