Skip to content

roguedan/specchain-reserve-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SpecChain β€” RWA Reserve-Backed Token (Week 1)

CI Security codecov Tests License: MIT

A minimal compliance-on-chain demo for reserve-backed tokens that enforces continuous solvency checks, bridging TradFi reserve requirements with blockchain transparency.

🎯 Features

  • βœ… 1:1 Reserve Backing: Every token is backed by equivalent reserves
  • βœ… Continuous Solvency Checks: All transfers validate reserve coverage
  • βœ… On-Chain Compliance: Reserve ratio events logged for audit trails
  • βœ… Access Control: Only authorized issuer can mint new tokens
  • πŸ”œ Oracle Integration: Real-world asset price feeds (Week 2)

πŸš€ Quick Start

Prerequisites

  • Foundry
  • Node.js 16+ (for additional tooling)

Installation

# Clone the repository
git clone https://github.com/yourusername/specchain-reserve-token
cd specchain-reserve-token

# Install dependencies
forge install

# Copy environment variables
cp .env.example .env
# Edit .env with your values

Running Tests

# Run all tests with gas reporting
forge test -vv --gas-report

# Run specific test
forge test --match-test testTransferSucceedsWhenReserveCoversSupply -vv

πŸ“Š Architecture

flowchart LR
    A[TradFi Legal Covenant<br/>1:1 Reserve] --> B[Specs/YAML]
    B --> C[Invariant Tests Foundry]
    C --> D[Smart Contract RwaToken]
    D --> E[On-Chain Proof<br/>Tx + Events]
    A -.Analogy.-> F[Custodian Bank]
    D -.Analogy.-> G[Transfer Agent/Registrar]
    E -.Analogy.-> H[Audit Trail]
Loading

πŸ§ͺ Test Coverage

Comprehensive Testing: 18 Tests, 100% Coverage

Core Functionality (3 tests)

Test Description Status
testTransferSucceedsWhenReserveCoversSupply Validates transfers work with adequate reserves βœ… Pass
testTransferRevertsWhenReserveBelowSupply Ensures transfers fail when reserves are insufficient βœ… Pass
testMintGatedByCoverage Confirms minting is blocked when it would break reserve ratio βœ… Pass

Security Testing (10 tests)

  • βœ… Access control validation
  • βœ… Overflow/underflow protection
  • βœ… Reentrancy attack prevention
  • βœ… Front-running protection
  • βœ… Reserve manipulation resistance
  • βœ… Gas optimization validation

Fuzz Testing (5 tests)

  • βœ… Random mint amounts (256 runs)
  • βœ… Multi-operation sequences (256 runs)
  • βœ… Reserve manipulation scenarios (256 runs)
  • βœ… Transfer edge cases (256 runs)
  • βœ… TransferFrom variations (256 runs)

Coverage Report: View detailed coverage on Codecov

πŸ“œ Smart Contract

Deployment

# Deploy to Sepolia testnet
source .env
forge script script/Deploy.s.sol:Deploy \
  --rpc-url $RPC_URL \
  --broadcast \
  --verify

Deployed Addresses

Deployment Configuration

  • Issuer: 0x61829Da7A106fcA416e143276c9cbCf63D66fccE
  • Reserve Wallet: 0x61829Da7A106fcA416e143276c9cbCf63D66fccE
  • Network: Sepolia Testnet (Chain ID: 11155111)
  • Gas Used: 1,331,617
  • Deployed: October 25, 2025

Key Functions

// Mint new tokens (only issuer)
function mint(address to, uint256 amount) external onlyIssuer

// Transfer with reserve check
function transfer(address to, uint256 amount) external returns (bool)

// Internal reserve validation
function _checkReserveBacking() internal returns (bool)

πŸ›οΈ TradFi ↔ Web3 Mapping

Traditional Finance On-Chain Implementation
Custodian Bank Reserve Wallet Address
Transfer Agent Smart Contract
Compliance Officer Modifier Checks
Audit Report Block Explorer Events
Reserve Requirement _checkReserveBacking()
Quarterly Audits Continuous On-Chain Verification

⚠️ Limitations (Demo Only)

  • Reserve Reading: Uses address.balance - production requires oracle feeds
  • Custody: Simple EOA wallet - production needs qualified custodian integration
  • Governance: No pause/upgrade mechanisms - production requires admin controls
  • Compliance: Basic implementation - production needs full KYC/AML integration

πŸ› οΈ Technical Skills

This project demonstrates expertise in:

πŸ“ˆ What's Next?

Week 2: Oracle integration for real-world asset prices Week 3: Multi-sig custody and governance Week 4: Cross-chain bridge for multi-network deployment Week 5: Compliance dashboard and reporting tools

πŸ“„ License

MIT License - see LICENSE for details

🀝 Contributing

Contributions are welcome! Please read our Contributing Guidelines first.

πŸ“ž Contact

About

specchain-reserve-token

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •