Skip to content

TrustUp-app/TrustUp-Contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

127 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TrustUp-Banner

Stellar Rust Soroban WASM

Open Source Rust Soroban SDK

Decentralized Buy Now Pay Later (BNPL) smart contracts on Stellar Network

Features β€’ Tech Stack β€’ Quick Start β€’ Documentation β€’ Contributing


πŸ“– About

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.

Key Features

  • ⭐ 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

πŸ›  Tech Stack

RS1.75 Β· SSDK22 Β· WASM Β· OZ Β· CARGO

Core Technologies

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

Smart Contracts

  • 🌟 Stellar Network - Layer 1 blockchain
  • πŸ”· Soroban - WASM smart contract platform
  • πŸ¦€ Rust - Memory-safe systems language
  • πŸ“¦ WASM - Portable bytecode format

πŸ“ Project Structure

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

πŸš€ Quick Start

Prerequisites

  • Rust 1.75 or higher
  • Cargo (included with Rust)
  • wasm32-unknown-unknown target
  • Stellar CLI (for deployment)

Installation

# 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 --locked

Configuration

No configuration needed for development. Contracts are stateless and configured at deployment time.

For deployment configuration, see Deployment Guide.

Running the Application

# 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

Contract Deployment

# 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>

πŸ§ͺ Testing

# 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 tarpaulin

πŸ“š Documentation

Comprehensive documentation is available in the docs/ folder:

Contract Documentation

Each contract includes inline documentation:

# Generate and view docs
cargo doc --open

# View specific contract docs
cargo doc -p reputation-contract --open

πŸ— Architecture Principles

  • πŸ”’ 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

πŸ” Security

  • Safe Arithmetic - checked_add/sub/mul/div to 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

Security Checklist

  • βœ… 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)

πŸ“¦ Contracts Overview

βœ… Reputation Contract (Complete)

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

⏳ CreditLine Contract (In Progress)

Handles loan creation, repayment, and default management.

Status: Partial implementation Progress: 67% complete (2/3 issues) Remaining: Loan repayment functionality

⏳ Merchant Registry (Planned)

Whitelist of authorized merchants.

Status: Not started Purpose: Validate merchants before loan creation

⏳ Liquidity Pool (Planned)

Manages LP deposits, withdrawals, and interest distribution.

Status: Not started Purpose: Fund loans and reward liquidity providers

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for:

  • Development setup
  • Code style guidelines
  • Testing requirements
  • Pull request process

Quick Contribution Guide

  1. Pick an issue from Issues
  2. Create branch: git checkout -b feat/SC-XX-description
  3. Follow standards: Code Style
  4. Write tests: Coverage goal >90%
  5. Run checks: cargo fmt && cargo clippy && cargo test
  6. Submit PR: Use the PR template

πŸ“Š Development Status

Current Progress: 11/20 Issues Complete (55%)

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.

πŸ™ Acknowledgments

πŸ“ž Support


πŸ† Top 3 Contributors


Built with ❀️ for the Stellar ecosystem

Stellar Soroban Open Source

About

Repository containing the TrustUp smart contracts, built with Rust and Soroban SDK on the Stellar network. Implements the on-chain logic for credit lines, reputation, escrows, and liquidity pools, ensuring secure and decentralized operations.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages