Skip to content

Open-audit-foundation/Open-Audit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

312 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open-Audit

The Google Translate for Soroban β€” an open-source transparency tool for the Stellar/Soroban ecosystem.

License: MIT Contributions Welcome Built on Stellar


πŸ“š Documentation Hub

Important

Looking for documentation? We have consolidated all guides into a centralized documentation index categorized by goal. Visit /docs/README.md to navigate directly to what you need:


What is Open-Audit?

Smart contracts on Stellar/Soroban emit events as cryptic, hex-encoded binary data. To the average user β€” or even most developers β€” these events are completely unreadable. Open-Audit solves this by:

  1. Fetching raw contract events from the Stellar network via Horizon/RPC.
  2. Translating them into plain English sentences using a community-maintained Translation Registry.
  3. Displaying the results in a clean, searchable dashboard anyone can use.

Example:

Before (Raw) After (Translated)
0x000000000000000000000000... Public Key [GABC...1234] transferred 100 USDC to [GXYZ...5678]

Try the translation playground live at /playground (no local setup required).

Tech Stack

  • Framework: Next.js 14 (App Router) + TypeScript
  • Design System: Tailwind CSS + shadcn/ui
  • Stellar Integration: stellar-sdk
  • State Management: React Context + Server Components

Getting Started

Prerequisites

  • Node.js >= 18
  • npm >= 9

Installation

git clone https://github.com/your-org/open-audit.git
cd open-audit
npm install
npm run dev

Open http://localhost:3000 in your browser.

For the recommended custom server with WebSocket support and /metrics, run:

npm run dev:decoupled

dev:ws starts the decoupled microservices web server. Start the indexer in a separate terminal with npm run worker:indexer when you need live chain events.

Environment Variables

Copy .env.example to .env.local and fill in the values:

cp .env.example .env.local

For microservices architecture, use:

cp .env.microservices.example .env.local
Variable Description Default
NEXT_PUBLIC_HORIZON_URL Stellar Horizon endpoint https://horizon-testnet.stellar.org
NEXT_PUBLIC_SOROBAN_RPC_URL Soroban RPC endpoint https://soroban-testnet.stellar.org
NEXT_PUBLIC_NETWORK_PASSPHRASE Network passphrase Testnet passphrase
REDIS_URL Redis connection URL (microservices) redis://localhost:6379
REDIS_CHANNEL Redis Pub/Sub channel (microservices) stellar:events
PORT HTTP server port 3000

Available Scripts

Development:

npm run dev              # Standard Next.js dev server
npm run dev:ws           # Recommended decoupled WebSocket server (requires Redis)
npm run dev:decoupled    # Microservices web server (requires Redis)
npm run worker:indexer   # Microservices indexer worker (requires Redis)
npm run dev:ws:legacy    # Deprecated monolithic WebSocket server; explicit legacy opt-in
npm run test:websocket   # Test WebSocket connection

Production (Microservices):

npm run docker:build     # Build Docker images
npm run docker:up        # Start all services with Docker Compose
npm run docker:down      # Stop all Docker services
npm run docker:logs      # View Docker logs

npm run start:pm2        # Start services with PM2
npm run stop:pm2         # Stop PM2 services
npm run monit:pm2        # Monitor PM2 processes
npm run logs:pm2         # View PM2 logs

Testing & Quality:

npm run test             # Run all tests
npm run lint             # Run ESLint
npm run lint:registry    # Validate translation registry
npm run format           # Format code with Prettier

Telemetry

The custom server exposes Prometheus metrics on http://localhost:3000/metrics when running npm run dev:decoupled.

You can configure OpenTelemetry to export spans to Jaeger by setting:

export JAEGER_ENDPOINT="http://localhost:14268/api/traces"
export OTEL_SERVICE_NAME="open-audit"

The default Jaeger endpoint is http://localhost:14268/api/traces.


Architecture

Open-Audit supports two deployment architectures:

πŸ†• Microservices Architecture (Recommended for Production)

Decoupled, scalable, fault-isolated system using Redis Pub/Sub:

Stellar Network β†’ Indexer Worker β†’ Redis Pub/Sub β†’ Web Server β†’ WebSocket Clients

Benefits:

  • βœ… Zero CPU starvation (indexer runs in separate process)
  • βœ… Independent horizontal scaling
  • βœ… Fault isolation (crashes don't affect other services)
  • βœ… Auto-reconnect and message queuing
  • βœ… Zero-downtime deployments

Quick Start:

# Option 1: Docker Compose (Easiest)
npm run docker:up

# Option 2: PM2 Process Manager
npm run start:pm2

# Option 3: Manual
Terminal 1: redis-server
Terminal 2: npm run dev:decoupled
Terminal 3: npm run worker:indexer

πŸ“š Documentation: For complete microservices instructions, architecture breakdowns, and testing guides, visit the Documentation Hub.

πŸ”’ Security Hardening (Production-Ready)

Bulletproof XDR parser protection against malicious contract payloads:

Untrusted XDR β†’ Security Guards β†’ Safe Parsing β†’ Graceful Error Handling

Protection Against:

  • βœ… Stack overflow (deeply nested structures)
  • βœ… Out-of-memory attacks (large payloads)
  • βœ… Denial of service (infinite loops)
  • βœ… Malformed XDR exploitation

Security Mechanisms:

  • Recursion depth limits (MAX=100 levels)
  • Memory allocation guards (MAX=10 MB)
  • Parsing timeout protection (MAX=5 seconds)
  • Collection size limits (MAX=10,000 elements)
  • Real-time attack detection

πŸ“š Documentation:

Quick Start:

import { secureParseScVal } from '@/lib/translator/secure-xdr-parser';

const result = secureParseScVal(hex);
if (result.success) {
  // Use result.value safely
}

Monitoring:

GET /api/security/metrics  # Security metrics API

Legacy Monolithic Architecture

Deprecated single-process system kept only for migration/debugging:

Stellar Network β†’ Event Indexer β†’ Translation Engine β†’ WebSocket Server β†’ Frontend Dashboard

⚠️ Known limitations: Under heavy load, indexing can starve the HTTP/WebSocket server of CPU cycles. See deprecation notice in server.ts. New development should use the microservices path above.

npm run dev:ws:legacy

The legacy script passes --legacy to server.ts. Direct invocations of server.ts without --legacy or OPEN_AUDIT_LEGACY_SERVER=1 exit immediately with a migration message so local scripts do not accidentally start the deprecated path.


For new contributors wanting to understand the system's data flow and internal architecture, see the comprehensive ARCHITECTURE.md guide which includes:

  • πŸ“Š Interactive Mermaid diagrams showing data flow
  • πŸ” Component deep dives for each service
  • πŸ“ Step-by-step event journey from blockchain to UI
  • πŸ› οΈ Development guides for adding new features

Quick Overview:

  1. Event Indexer (lib/stellar/, src/worker/) β€” Polls Stellar RPC with resilient rate limiting
  2. Translation Engine (lib/translator/) β€” Converts XDR to human-readable text with security hardening
  3. Redis Pub/Sub (microservices only) β€” Message broker for event distribution
  4. WebSocket Server (server-decoupled.ts) β€” Broadcasts events in real-time; server.ts is deprecated and available only through dev:ws:legacy
  5. Frontend Dashboard (app/dashboard/, components/) β€” Interactive UI

Project Structure

open-audit/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ dashboard/          # Main dashboard page
β”‚   β”œβ”€β”€ api/                # API routes (health checks, etc.)
β”‚   β”œβ”€β”€ layout.tsx          # Root layout with theme provider
β”‚   └── page.tsx            # Landing / redirect
β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”œβ”€β”€ ui/                 # shadcn/ui primitives
β”‚   β”œβ”€β”€ dashboard/          # Dashboard-specific components
β”‚   └── theme/              # Dark mode toggle
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ translator/         # πŸ”‘ The Translation Registry core logic
β”‚   β”‚   β”œβ”€β”€ types.ts        # RawEvent / TranslatedEvent interfaces
β”‚   β”‚   β”œβ”€β”€ registry.ts     # Registry lookup function
β”‚   β”‚   └── blueprints/     # Per-contract translation blueprints
β”‚   β”œβ”€β”€ stellar/            # Stellar SDK helpers
β”‚   β”‚   β”œβ”€β”€ indexer.ts      # Event polling with rate limit handling
β”‚   β”‚   └── client.ts       # RPC client configuration
β”‚   β”œβ”€β”€ resilience/         # ⚑ Rate limiting & circuit breaker
β”‚   β”‚   β”œβ”€β”€ token-bucket.ts # Token bucket rate limiter
β”‚   β”‚   β”œβ”€β”€ circuit-breaker.ts # Circuit breaker pattern
β”‚   β”‚   └── resilient-client.ts # Resilient RPC client wrapper
β”‚   β”œβ”€β”€ hooks/              # React hooks for live data
β”‚   └── utils.ts            # Shared utilities
β”œβ”€β”€ src/
β”‚   └── worker/             # πŸ†• Microservices architecture
β”‚       └── indexer.ts      # Standalone indexer worker
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ lint-registry.ts    # Translation registry validation
β”‚   └── test-websocket-client.js # WebSocket testing tool
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ README.md           # πŸ“š Centralized documentation hub
β”‚   β”œβ”€β”€ archive/            # πŸ“œ Historical PR write-ups & summaries
β”‚   └── good-first-issues.json
β”œβ”€β”€ server.ts               # Legacy monolithic server (deprecated)
β”œβ”€β”€ server-decoupled.ts     # πŸ†• Microservices web server
β”œβ”€β”€ ecosystem.config.js     # πŸ†• PM2 configuration
β”œβ”€β”€ docker-compose.microservices.yml # πŸ†• Docker Compose config
β”œβ”€β”€ Dockerfile.worker       # πŸ†• Indexer worker Docker image
β”œβ”€β”€ Dockerfile.web          # πŸ†• Web server Docker image
β”œβ”€β”€ ARCHITECTURE.md         # πŸ“– Detailed architecture guide
β”œβ”€β”€ MICROSERVICES_ARCHITECTURE.md # πŸ†• Microservices documentation
β”œβ”€β”€ QUICKSTART_MICROSERVICES.md   # πŸ†• Quick start guide
β”œβ”€β”€ MICROSERVICES_TESTING_GUIDE.md # πŸ†• Testing guide
└── public/

The Translation Registry

The heart of Open-Audit is the Translation Registry in /lib/translator/. Each contract gets a blueprint β€” a mapping from raw event topics/data to a human-readable template.

To add support for a new contract, create a file in /lib/translator/blueprints/ and register it in registry.ts. See CONTRIBUTING.md for a step-by-step guide.


πŸ› οΈ Developer Tools

open-audit-cli - Standalone Blueprint Testing

Instant offline testing for translation blueprints β€” no database, no network, no services required.

# Install and build
npm install
npm run build:cli

# Test a specification
node dist/cli/open-audit-cli.js test \
  --hex 0x74726e7312345678 \
  --spec ./blueprints/my-contract.json \
  --verbose

Benefits:

  • βœ… 17x faster iteration cycle vs. full system
  • βœ… Zero setup - Node.js only
  • βœ… Works offline
  • βœ… JSON & YAML support
  • βœ… CI/CD integration ready

πŸ“š Documentation:

Quick Example:

npm run cli:example

Output:

βœ… Translation Successful
Description: GABC...1234 transferred 100.00 USDC to GXYZ...5678

πŸ”’ WASM Sandbox for Community Parsers (NEW)

Secure execution environment for third-party contract parsers:

Untrusted WASM β†’ Sandbox β†’ Zero Host Access β†’ Strict Limits β†’ Safe Execution

Security Features:

  • βœ… Zero host capabilities (no filesystem, network, or env access)
  • βœ… Memory limits (16MB maximum per execution)
  • βœ… Execution timeouts (5 seconds maximum)
  • βœ… Worker thread isolation (crashes don't affect main process)
  • βœ… Input/output validation (size and schema checks)

Why WASM?

  • Community developers can write custom parsers for idiosyncratic contracts
  • Zero RCE risk - parsers run in complete isolation
  • Near-native performance with minimal overhead (~60-120ms)
  • Industry-standard sandboxing technology

πŸ“š Documentation:

Quick Start (Parser Development):

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

# Build example parsers
cd lib/wasm-sandbox/examples/rust
./build-all.sh  # or build-all.bat on Windows

# Test your parser
npm run test:wasm:manual custom ./my-parser.wasm

# Run test suite
npm run test:wasm

Example Usage:

import { WasmSandboxRunner } from '@/lib/wasm-sandbox';

const runner = new WasmSandboxRunner();

const result = await runner.execute('./parser.wasm', {
  data: JSON.stringify({ from: 'G...', to: 'G...', amount: '1000000' }),
  contractId: 'CDLZ...YSC',
  eventType: 'transfer'
});

if (result.success) {
  console.log(result.output.description);  // "Transferred 1000000..."
}

Contributing

We welcome contributions of all sizes! See CONTRIBUTING.md to get started.

Good first issues are listed in /docs/good-first-issues.json.


License

MIT Β© Open-Audit Contributors

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors