A comprehensive implementation of Buy Now Pay Later functionality for Bitcoin Ordinals, enabling collectors to acquire premium Ordinals without paying the full amount upfront.
If you need any consultant or feedback for devs, contact him via whatsApp(+44 7832607596) or telegram - mooneagle1_1
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
- 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
npm installCreate 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_keynpm run devThe API will be available at http://localhost:3000
POST /api/bnpl/purchase
Content-Type: application/json
{
"listingId": "listing_123",
"buyerAddress": "bc1...",
"downPaymentPercentage": 30,
"loanDuration": 14,
"buyerUTXOs": [...]
}POST /api/bnpl/repay
Content-Type: application/json
{
"loanId": "loan_123",
"borrowerAddress": "bc1...",
"repaymentUTXOs": [...]
}POST /api/bnpl/claim
Content-Type: application/json
{
"loanId": "loan_123",
"lenderAddress": "bc1..."
}- Buyer selects Ordinal with BNPL available on Satflow
- Buyer chooses BNPL option at checkout (20-40% down payment)
- Buyer pays down payment (e.g., 30% of listing price)
- Lender provides loan via Liquidium.WTF for remaining amount
- Ordinal enters escrow (non-custodial)
- Buyer repays loan within duration (7-30 days) → Ordinal released
- If buyer defaults → Lender claims Ordinal from escrow
- 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
- Buyer prepares UTXOs for partial BTC payment
- Seller signs Tx1 (listing) and Tx2 (sale)
- Buyer initiates BNPL purchase request
- PSBT for Tx2 is constructed with Ordinal + loan logic
- Buyer signs Tx2 with ALL (agrees to terms)
- Liquidium.WTF canister signs with ALL (validates and provides loan)
- Satflow signs 2/2 inscription spend (finalizes Ordinal transfer)
- Tx1 and Tx2 are broadcast
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
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
React component for managing active loans with:
- Loan list display
- Days remaining countdown
- Repayment button
- Expiration warnings
# Build TypeScript
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
# Lint code
npm run lintIn 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