Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Legatia/OuroC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OuroC - Decentralized Recurring Transactions on Solana

πŸš€ Proof-of-Concept Subscription Infrastructure - ICP Timer + Solana Smart Contract

Decentralized recurring payment protocol combining Solana's speed with ICP's autonomous scheduling for truly automated subscriptions.


🎯 What is OuroC?

OuroC is a proof-of-concept implementation of decentralized recurring transactions on Solana, powered by Internet Computer Protocol (ICP) autonomous scheduling.

πŸ›οΈ OuroC-Mesos: The Timer Canister

OuroC-Mesos is the core ICP canister that provides autonomous scheduling for Solana subscriptions. It serves as the bridge between ICP timer logic and Solana smart contracts.

What Mesos Does:

  • πŸ€– Autonomous Timer Management - Schedules recurring subscription payments without centralized dependencies
  • πŸ” Threshold Ed25519 Signing - Uses ICP's Schnorr signature scheme to sign Solana transactions
  • πŸ“‘ Cross-Chain Communication - Bridges ICP timer logic with Solana smart contracts via HTTP outcalls
  • ⚑ Opcode Routing - Processes payment (opcode 0) and notification (opcode 1) triggers
  • πŸ’Ύ Subscription State Management - Maintains subscription metadata, execution times, and failure handling
  • πŸ”„ Exponential Backoff - Automatically retries failed payments with intelligent backoff strategy

Architecture:

ICP Timer Canister (OuroC-Mesos)
    β”œβ”€β”€ Subscription Manager (creates/pauses/cancels subscriptions)
    β”œβ”€β”€ Timer Module (schedules execution via ic_cdk_timers)
    β”œβ”€β”€ Threshold Ed25519 (signs payment messages with 50B cycles)
    β”œβ”€β”€ Solana RPC Client (HTTP outcalls to Solana devnet/mainnet)
    └── State Management (stable storage for upgrades)
            ↓
    Solana Smart Contract (OuroC-Prima)
        β”œβ”€β”€ Process payment (splits merchant/platform fee)
        β”œβ”€β”€ Send notification (1 day before payment for intervals > 1 day)
        └── Delegate authority (PDA pulls USDC from subscriber)

Key Technical Details:

  • Delegation Model: Subscribers approve subscription PDA to spend USDC (1 year of payments by default)
  • Fee Calculation: Platform takes 2% (200 basis points), merchant receives 98%
  • Signature Cost: 50 billion cycles per Schnorr Ed25519 signature (increased from 27B for reliability)
  • Cycle Monitoring: Built-in balance checks to prevent signing failures (minimum 100B cycles required)
  • Network Support: Solana devnet (active) and mainnet (prepared)

Built on OuroC-Prima: Mesos is the first application built on top of the OuroC-Prima subscription smart contract, demonstrating how the decentralized recurring payment protocol works.


πŸ—οΈ Architecture

Minimalist Design: Solana = source of truth, ICP = lightweight scheduler

Subscriber β†’ Solana Contract (subscription data + PDA delegation)
                    ↓
              ICP Timer Canister (autonomous scheduling)
                    ↓
           Solana Router (opcode 0=payment, 1=notification)
                    ↓
              Token Processing:
              β€’ USDC β†’ Direct transfer
              β€’ Fee split β†’ Merchant (98%) + Platform (2%)

πŸ”‘ PDA Structure

  1. Config PDA (["config"]) - Global configuration
  2. Subscription PDA (["subscription", subscription_id]) - Individual subscription management

Key Innovation: Subscription PDA acts as delegate authority for automated recurring payments.


πŸ” Delegation Amount Calculation

The delegation amount determines how much USDC the subscription PDA can spend on behalf of the subscriber.

Frontend Implementation (TypeScript)

Formula: 12 Months of Payments

export function calculateDelegationAmount(
  amountPerPayment: number,
  intervalSeconds: number
): number {
  // One-time payment
  if (intervalSeconds === -1) {
    return amountPerPayment;
  }

  // Estimate number of payments in 12 months
  const secondsPerMonth = 30 * 24 * 60 * 60;
  const monthsToApprove = 12;
  const estimatedPayments = Math.ceil((monthsToApprove * secondsPerMonth) / intervalSeconds);

  // Cap between 1-100 payments
  const paymentsToApprove = Math.max(1, Math.min(100, estimatedPayments));

  return amountPerPayment * paymentsToApprove;
}

Smart Contract Implementation (Rust)

Formula: One Year of Payments + Buffer

pub fn calculate_one_year_delegation(amount: u64, interval_seconds: i64) -> Result<u64> {
    const SECONDS_IN_YEAR: i64 = 365 * 24 * 60 * 60; // 31,536,000 seconds

    if interval_seconds == -1 {
        return Ok(amount); // One-time payment
    }

    // Calculate payments per year + 1 buffer for clock drift
    let payments_per_year = (SECONDS_IN_YEAR / interval_seconds) as u64;
    let total_payments = payments_per_year + 1;

    // Total delegation = amount Γ— (payments_per_year + 1)
    let delegation = amount * total_payments;

    // Cap at MAX_APPROVAL_AMOUNT (1M USDC)
    Ok(delegation.min(MAX_APPROVAL_AMOUNT))
}

Examples

Subscription Amount Interval Delegation
Monthly 10 USDC 30 days 120-130 USDC (1 year)
Weekly 5 USDC 7 days 260-265 USDC (1 year)
Daily 1 USDC 1 day 100-366 USDC (capped/full year)
One-time 100 USDC -1 100 USDC (exact amount)

User Experience: Approve once for a full year of payments, balancing convenience with security.


πŸš€ Quick Start

Prerequisites

# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

# Install dfx (ICP SDK)
sh -c "$(curl -fsSL https://internetcomputer.org/install.sh)"

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Deploy Timer Canister (ICP)

cd OuroC-Mesos

# Start local ICP replica
dfx start --background

# Deploy timer canister
dfx deploy timer_rust

# Get canister ID
dfx canister id timer_rust

Deploy Solana Contract

cd solana-contract/ouroc_prima

# Build contract
anchor build

# Deploy to devnet
anchor deploy --provider.cluster devnet

# Get program ID
solana address -k target/deploy/ouroc_prima-keypair.json

Run Frontend

cd OuroC-Mesos/frontend

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your canister ID and program ID

# Run dev server
npm run dev

🌐 Network Configuration

Development (Devnet)

  • Timer Canister: ar3bl-2aaaa-aaaag-auhda-cai (IC mainnet)
  • Solana Program: CFEtrptTe5eFXpZtB3hr1VMGuWF9oXguTnUFUaeVgeyT
  • USDC Mint: 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
  • RPC: https://api.devnet.solana.com

πŸ“Š Technology Stack

Layer Technology Purpose
Blockchain Solana + Anchor Payment execution, immutable audit trail
Scheduler ICP (Rust) Autonomous payment scheduling with Threshold Ed25519
Frontend React + Vite + Shadcn UI User interface for subscription management
Wallet Solana Wallet Adapter Connect Phantom, Solflare, etc.

πŸ” Security Features

  • βœ… Ed25519 Signature Verification - ICP ↔ Solana cross-chain signatures
  • βœ… Payment Delegation - Users approve max amount + duration, not blank checks
  • βœ… Proper PDA Derivation - SHA256-based Program Derived Addresses
  • βœ… Pausable - Users can pause/cancel anytime
  • βœ… Transparent - All transactions on-chain and auditable
  • βœ… Exponential Backoff - Intelligent retry logic for failed payments
  • βœ… Cycle Monitoring - Prevents canister from running out of cycles

πŸ“ˆ Use Cases

πŸ’Ό Proof-of-Concept Applications

  • SaaS Subscriptions - Monthly/annual billing automation
  • Content Platforms - Creator subscription payments
  • Developer Tools - API access with tiered pricing
  • Research - Demonstrate decentralized scheduling capabilities

πŸ›£οΈ Project Status

βœ… Implemented (Q4 2025)

  • βœ… Core subscription system with USDC support
  • βœ… ICP timer integration with Threshold Ed25519
  • βœ… Solana smart contract (OuroC-Prima)
  • βœ… Basic frontend with Solana wallet integration
  • βœ… Delegation amount calculation (1 year of payments)
  • βœ… Fee split (98% merchant, 2% platform)
  • βœ… Notification system (1 day before payment)
  • βœ… Exponential backoff for failed payments
  • βœ… Devnet deployment

🚧 In Progress

  • πŸ”„ Smart contract audit
  • πŸ”„ Mainnet deployment preparation
  • πŸ”„ Documentation improvements

🎯 Future Considerations

  • πŸ“¦ NPM SDK package
  • πŸ€– AI agent payment delegation
  • 🏦 Enterprise compliance features
  • πŸ’° Multi-token support (Jupiter DEX)
  • πŸ“± Mobile application

🀝 Contributing

We welcome contributions! The codebase is organized as follows:

OuroC/
β”œβ”€β”€ OuroC-Mesos/              # ICP timer canister
β”‚   β”œβ”€β”€ src/timer_rust/      # Rust canister code
β”‚   └── frontend/            # React frontend
β”œβ”€β”€ solana-contract/          # Solana smart contracts
β”‚   └── ouroc_prima/         # OuroC-Prima subscription contract
└── Archive/                  # Previous implementations (reference only)

Development Setup

# Clone repository
git clone https://github.com/yourusername/ouroc.git
cd ouroc

# Install dependencies
npm install

# Run local development
# See Quick Start section above

πŸ“„ License

MIT License - see LICENSE for details


πŸ™ Acknowledgments

Built with:

  • Solana - High-performance blockchain
  • Internet Computer - Decentralized cloud computing with Threshold signatures
  • Anchor - Solana smart contract framework

Made with ❀️ by the OuroC Team

Proof-of-Concept: Decentralized Recurring Transactions on Solana

About

A Fully on-chain, compliance aligned subscription tool for Solana

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •