💡 Inspiration
The global financing gap for Small and Medium Enterprises (SMEs) is estimated at over $5.2 trillion. Millions of businesses face a critical cash flow problem: they deliver goods today but wait 30, 60, or even 90 days to get paid. Traditional invoice factoring is slow, burdened by paperwork, and dominated by centralized banks with high fees.
We asked ourselves: What if we could turn these idle invoices into liquid assets instantly?
Inspired by the concept of Real-World Assets (RWA) and the efficiency of the XRP Ledger, we built InvoiceXRP. Our goal was to democratize access to capital by creating a decentralized marketplace where invoices are transparent, liquid, and settled instantly using stablecoins like RLUSD.
How we built it
We architected InvoiceXRP as a hybrid Web3 application, combining the user experience of Web2 with the trustless security of Web3.
1. The Core Architecture
- Blockchain: We leveraged the XRP Ledger (XRPL) for its speed (<4s latency) and low cost (<0.0002 XRP per tx).
- Backend: A Node.js/Express server acts as the bridge, indexing blockchain events into a PostgreSQL database for real-time querying.
- Frontend: Built with React and Vite for a seamless dashboard experience.
2. Key Technical Implementations
We utilized three specific capabilities of XRPL:
- NFTs (XLS-20): Every invoice uploaded is minted as a unique NFToken. The metadata (Buyer info, Due Date, Amount) is hashed and stored immutably.
- Stablecoin Settlement (RLUSD): To mitigate crypto volatility, we integrated a custom RLUSD Issuer model. Sellers and Investors establish Trustlines to transact in stable value.
- Smart Escrows: We replaced traditional middlemen with code. When an investor funds an invoice, the capital is locked in an XRPL Escrow, ensuring funds are only released when conditions are met.
3. The Financial Logic
We implemented an on-chain discount mechanism. The Return on Investment (ROI) for investors is calculated as:
$$ ROI = \left( \frac{FaceValue - PurchasePrice}{PurchasePrice} \right) \times 100 $$
Where the Purchase Price is determined by the discount rate ($r$) set by the SME:
$$ PurchasePrice = FaceValue \times \left(1 - \frac{r}{100}\right) $$
Challenges we faced
Building a fintech product on blockchain came with unique hurdles:
- The "Chicken and Egg" of RLUSD: Since RLUSD is not yet widely available on public faucets for Hackathon environments, we had to architect a Self-Issued Token model. We created a mock "Central Bank" node to issue wrapped USD tokens, mimicking the behavior of the real RLUSD to demonstrate stable settlements.
- Handling Precision: One specific bug caused our dashboard to crash when rendering financial data. PostgreSQL returns aggregated data (like average discount rates) as strings to preserve precision, while our frontend expected numbers. We had to implement strict type-casting and serialization layers to ensure accurate financial reporting.
- Escrow Logic: XRPL's native Escrow works primarily with XRP. Implementing conditional release logic for Issued Currencies (like our RLUSD) required complex workarounds using multi-signature setups or specialized Hashed Time-Lock Contracts (HTLC) logic.
What we learned
- Trustlines are powerful: We gained a deep understanding of how XRPL handles issued assets via Trustlines (RippleState), which is fundamentally different from the ERC-20
approvemodel. - RWA Potential: Tokenizing invoices isn't just a buzzword; it legally transforms a debt instrument into a digital asset that can be collateralized.
- Full-Stack Complexity: Balancing on-chain finality with off-chain database synchronization is the key to a smooth user experience.
What's next for InvoiceXRP
- DID Integration: Implementing Decentralized Identifiers (W3C DID) for automated, privacy-preserving KYC/KYB.
- Secondary Market: Allowing investors to trade fractionalized parts of an invoice.
- Mainnet Launch: Transitioning from our self-issued token to the official Ripple RLUSD upon public release.
Built With
- escrow
- express.js
- javascript
- nft
- node.js
- postgresql
- react
- sql
- tailwind-css
- typescript
- vite
- xrp-ledger
- xrpl
- xrpl.js
Log in or sign up for Devpost to join the conversation.