Decentralized Buy Now Pay Later (BNPL) smart contracts on Stellar Network
Features β’ Tech Stack β’ Quick Start β’ Documentation β’ Contributing
TrustUp Contracts is a suite of production-ready smart contracts powering decentralized Buy Now Pay Later (BNPL) on Stellar blockchain. Built with Rust and Soroban, it provides on-chain reputation, credit line management, merchant validation, and liquidity pool functionality.
- β On-chain Reputation - Immutable credit scores (0-100) with admin controls
- π° Credit Line Management - Loan creation, repayment, and default handling
- πͺ Merchant Registry - Whitelist of authorized merchants
- π§ Liquidity Pool - LP deposits, withdrawals, and interest distribution
- π Access Control - Role-based permissions (admin, updaters)
- π Event Emission - Complete audit trail on-chain
- π§ͺ Battle-tested - Comprehensive test coverage (37+ tests)
- π Security First - Safe arithmetic, input validation, OpenZeppelin patterns
RS1.75 Β· SSDK22 Β· WASM Β· OZ Β· CARGO
| Category | Technology | Version |
|---|---|---|
| Language | Rust | 1.75+ |
| SDK | Soroban SDK | 22.0.0 |
| Platform | Stellar Soroban | Mainnet |
| Build | Cargo | Latest |
| Target | wasm32-unknown-unknown | - |
| Security | OpenZeppelin Stellar | Main |
| Testing | Soroban Testutils | 22.0.0 |
- π Stellar Network - Layer 1 blockchain
- π· Soroban - WASM smart contract platform
- π¦ Rust - Memory-safe systems language
- π¦ WASM - Portable bytecode format
TrustUp-Contracts/
βββ contracts/
β βββ reputation-contract/ # β
User credit scores (0-100)
β βββ creditline-contract/ # β³ Loan management
β βββ merchant-registry-contract/ # β³ Merchant whitelist
β βββ liquidity-pool-contract/ # β³ LP management
βββ docs/
β βββ architecture/ # System architecture
β β βββ overview.md # Tech stack and design
β β βββ contracts.md # Contract details
β β βββ storage-patterns.md # Storage strategies
β βββ standards/ # Code standards
β β βββ error-handling.md # Error patterns
β β βββ file-organization.md # Project structure
β β βββ code-style.md # Rust style guide
β βββ development/ # Dev workflows
β β βββ README.md # Setup and tools
β βββ resources/ # External resources
β βββ openzeppelin.md # OpenZeppelin tools
β βββ stellar-soroban.md # Stellar docs
β βββ ai-assistants.md # MCP servers
βββ target/
β βββ wasm32-unknown-unknown/
β βββ release/*.wasm # Deployable contracts
βββ Cargo.toml # Workspace config
βββ CONTRIBUTING.md # Contribution guide
βββ PROJECT_CONTEXT.md # Project vision
βββ README.md # This file
- Rust 1.75 or higher
- Cargo (included with Rust)
- wasm32-unknown-unknown target
- Stellar CLI (for deployment)
# Clone the repository
git clone https://github.com/TrustUp-app/TrustUp-Contracts.git
cd TrustUp-Contracts
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add WASM target
rustup target add wasm32-unknown-unknown
# Install Stellar CLI (optional, for deployment)
cargo install stellar-cli --lockedNo configuration needed for development. Contracts are stateless and configured at deployment time.
For deployment configuration, see Deployment Guide.
# Check compilation
cargo check
# Run tests
cargo test
# Build all contracts (native)
cargo build --release
# Build WASM for deployment
cargo build -p reputation-contract --target wasm32-unknown-unknown --release
# Output: target/wasm32-unknown-unknown/release/reputation_contract.wasm# Deploy to testnet
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/reputation_contract.wasm \
--source alice \
--network testnet
# Initialize contract
stellar contract invoke \
--id <CONTRACT_ID> \
--source alice \
--network testnet \
-- \
initialize --admin <ADMIN_ADDRESS># Run all tests
cargo test
# Run tests for specific contract
cargo test -p reputation-contract
# Run specific test
cargo test test_increase_score
# Run with output
cargo test -- --nocapture
# Check code coverage
cargo tarpaulinComprehensive documentation is available in the docs/ folder:
- Architecture Overview - System design and tech stack
- Contract Details - Individual contract specs
- Storage Patterns - Data management
- Error Handling - Error codes and patterns
- Code Style Guide - Rust conventions
- File Organization - Project structure
- OpenZeppelin Tools - Security libraries
- Stellar & Soroban - Platform docs
- AI Assistants & MCP - Development tools
- Contributing Guide - Development workflow
- Project Context - Vision and use cases
Each contract includes inline documentation:
# Generate and view docs
cargo doc --open
# View specific contract docs
cargo doc -p reputation-contract --open- π Security First - Safe arithmetic, input validation, comprehensive tests
- π Event-driven - All state changes emit events for indexing
- π§© Modular - Independent contracts with clear interfaces
- β‘ Gas Optimized - WASM size <64KB, minimal storage operations
- β Battle-tested - Extensive test coverage, OpenZeppelin patterns
- π Composable - Contracts designed for integration
- Safe Arithmetic -
checked_add/sub/mul/divto prevent overflow - Input Validation - All inputs validated before processing
- Access Control - Role-based permissions (admin, updaters)
- Event Emission - Complete audit trail
- OpenZeppelin - Industry-standard security patterns
- Comprehensive Testing - 37+ tests covering edge cases
- β Authorization checks before state changes
- β Safe arithmetic operations
- β Input validation and range checks
- β Event emission for all mutations
- β Fail securely (panic on unexpected conditions)
- β³ External security audit (planned)
Manages user credit scores (0-100) with role-based access control.
Status: Deployed to testnet
Tests: 37 passing
Functions: get_score, increase_score, decrease_score, set_admin, set_updater
Handles loan creation, repayment, and default management.
Status: Partial implementation Progress: 67% complete (2/3 issues) Remaining: Loan repayment functionality
Whitelist of authorized merchants.
Status: Not started Purpose: Validate merchants before loan creation
Manages LP deposits, withdrawals, and interest distribution.
Status: Not started Purpose: Fund loans and reward liquidity providers
We welcome contributions! Please see our Contributing Guide for:
- Development setup
- Code style guidelines
- Testing requirements
- Pull request process
- Pick an issue from Issues
- Create branch:
git checkout -b feat/SC-XX-description - Follow standards: Code Style
- Write tests: Coverage goal >90%
- Run checks:
cargo fmt && cargo clippy && cargo test - Submit PR: Use the PR template
| Phase | Status | Progress |
|---|---|---|
| Phase 1: Access Control | β Complete | 100% |
| Phase 2: Reputation | β Complete | 100% |
| Phase 3: CreditLine Core | β³ Partial | 67% |
| Phase 4: Integration | β³ Partial | 0% |
| Phase 5: Merchant Registry | β³ Pending | 0% |
| Phase 6: Liquidity Pool | β³ Pending | 0% |
| Phase 7: Testing | β³ Partial | 33% |
See ROADMAP.md for detailed breakdown.
- Stellar Development Foundation - For the Soroban platform
- OpenZeppelin - For security standards and tools
- Rust Community - For the amazing language
- π Documentation
- π Issue Tracker
- π¬ Discussions
- π» Smart Contracts
- π API Backend
|
π₯ @KevinMB0220 9 contributions |
π₯ @Bosun-Josh121 8 contributions |
π₯ @ryzen-xp 6 contributions |