Skip to content

Bitcoin bnpl(buy now pay late) script for lending and borrowing like satflow and liquidium.wtf

Notifications You must be signed in to change notification settings

forward0507/bnpl-bitcoin-satflow-liquidium-script-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Buy Now Pay Later (BNPL) Fork for Bitcoin Ordinals (Public Version)

A comprehensive implementation of Buy Now Pay Later functionality for Bitcoin Ordinals, enabling collectors to acquire premium Ordinals without paying the full amount upfront.

Contact to Dev

If you need any consultant or feedback for devs, contact him via whatsApp(+44 7832607596) or telegram - mooneagle1_1

image

Overview

This system enables BNPL purchases through integration with:

  • Satflow: Marketplace for Bitcoin Ordinals
  • Liquidium.WTF: Peer-to-peer lending platform powered by ICP's Chain Fusion

Features

  • BNPL purchase flow with down payment (20-40%)
  • Loan management (7, 10, 14, or 30 days)
  • Escrow system for Ordinals
  • PSBT (Partially Signed Bitcoin Transaction) construction
  • Fee calculation (Satflow fees, activation fees, interest)
  • Repayment processing
  • Default handling and liquidation
  • Transaction size validation
  • REST API endpoints
  • React frontend components

Installation

npm install

Configuration

Create a .env file:

PORT=3000
SATFLOW_API_URL=https://api.satflow.com
SATFLOW_API_KEY=your_satflow_api_key
LIQUIDIUM_API_URL=https://api.liquidium.wtf
LIQUIDIUM_CANISTER_ID=your_canister_id
LIQUIDIUM_API_KEY=your_liquidium_api_key

Usage

Start the API server

npm run dev

The API will be available at http://localhost:3000

API Endpoints

Initiate BNPL Purchase

POST /api/bnpl/purchase
Content-Type: application/json

{
  "listingId": "listing_123",
  "buyerAddress": "bc1...",
  "downPaymentPercentage": 30,
  "loanDuration": 14,
  "buyerUTXOs": [...]
}

Repay Loan

POST /api/bnpl/repay
Content-Type: application/json

{
  "loanId": "loan_123",
  "borrowerAddress": "bc1...",
  "repaymentUTXOs": [...]
}

Claim Defaulted Loan

POST /api/bnpl/claim
Content-Type: application/json

{
  "loanId": "loan_123",
  "lenderAddress": "bc1..."
}

How BNPL Works

  1. Buyer selects Ordinal with BNPL available on Satflow
  2. Buyer chooses BNPL option at checkout (20-40% down payment)
  3. Buyer pays down payment (e.g., 30% of listing price)
  4. Lender provides loan via Liquidium.WTF for remaining amount
  5. Ordinal enters escrow (non-custodial)
  6. Buyer repays loan within duration (7-30 days) → Ordinal released
  7. If buyer defaults → Lender claims Ordinal from escrow

Fee Structure

  • Down Payment: 20-40% of purchase price
  • Satflow Fee: 1.5% of full purchase amount
  • Activation Fee: 0.75% of loan amount
  • Interest: Based on loan amount and duration (APR)
  • Bitcoin Transaction Fee: Network fee

Technical Details

PSBT Flow

  1. Buyer prepares UTXOs for partial BTC payment
  2. Seller signs Tx1 (listing) and Tx2 (sale)
  3. Buyer initiates BNPL purchase request
  4. PSBT for Tx2 is constructed with Ordinal + loan logic
  5. Buyer signs Tx2 with ALL (agrees to terms)
  6. Liquidium.WTF canister signs with ALL (validates and provides loan)
  7. Satflow signs 2/2 inscription spend (finalizes Ordinal transfer)
  8. Tx1 and Tx2 are broadcast

Transaction Size Validation

The system validates transaction size to prevent "transaction too large" errors:

  • Checks input count against Bitcoin standardness rules
  • Estimates transaction size before construction
  • Rejects transactions exceeding 100KB limit

Frontend Components

BNPLCheckout

React component for BNPL checkout flow with:

  • Down payment slider (20-40%)
  • Loan duration selector (7, 10, 14, 30 days)
  • Fee breakdown display
  • Purchase button

LoanManagement

React component for managing active loans with:

  • Loan list display
  • Days remaining countdown
  • Repayment button
  • Expiration warnings

Development

# Build TypeScript
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

In the PREMIUM Version, there are more features like following...

  • Implement proper UTXO fetching and management
  • Add comprehensive error handling
  • Implement proper Bitcoin transaction construction
  • Add security audits
  • Implement proper wallet integrations
  • Add comprehensive testing

About

Bitcoin bnpl(buy now pay late) script for lending and borrowing like satflow and liquidium.wtf

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •