Skip to content

RobertSamuel-tech/Nexora

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Nexora Treasury

Real-time on-chain payroll streaming infrastructure with group distribution and intelligent treasury analytics.


Overview

Nexora Treasury is a production-grade platform for programmable, continuous on-chain payroll. It enables per-second fund distribution to any number of recipients, backed by fraud risk analysis, NLP-assisted stream creation, a treasury optimization agent, and an autonomous keeper for protocol liveness.

Built on Somnia Testnet — a high-throughput, low-latency blockchain optimised for real-time financial primitives.


Core Features

Feature Description
Real-time streams Per-second fund distribution using on-chain flow rate logic
Group payroll Single transaction distributes to multiple recipients
NLP input Natural language stream creation via AI parsing
Fraud detection Pre-transaction risk scoring (local heuristics + Gemini AI)
Treasury agent Rule-based optimization engine with Gemini executive summary
Autonomous keeper Background agent monitors and batches stream updates when profitable
Cashflow analytics 90-day projection, burn rate, and runway estimation
Risk dashboard Per-stream risk scores with actionable recommendations
Template system Save and reuse stream configurations via StreamFactory

Architecture

Nexora Smart Contracts

Nexora Core Payroll Engine

Nexora's core engine for real-time fund custody and stream lifecycle.

Handles all fund custody and stream lifecycle:

createStream(recipient, amount, duration, streamType)
withdrawFromStream(streamId)
batchUpdateStreams(streamIds[])

Contract Address: 0xaa6db326ffc44b999bca1d91b802e99f9d9fcd29 (View on Explorer)


Nexora Template Engine

Enables reusable stream configurations:

createTemplate(name, rate, duration, category)
createStreamFromTemplate(templateId, recipient)

Contract Address: 0x2518849a677efde604e19b1a40843bccdcedb9ec (View on Explorer)


Nexora Keeper Engine

Owner-controlled fallback keeper for protocol liveness:

Contract Address: 0x52dd3180486eecf923343b99c91e8a71403113fa (View on Explorer)


AI Agents

Agent 1 — NLP Stream Parser

  • Trigger: User enters a natural language description in the create-stream form
  • Endpoint: POST /api/parse-stream
  • Model: Google Gemini
  • Output: { recipient, amount, duration, durationUnit, streamType }

Agent 2 — Fraud Risk Analyzer

  • Trigger: User submits stream creation
  • Endpoint: POST /api/check-fraud
  • Pipeline: Local heuristics → Gemini contextual analysis
  • Output: { riskScore, riskFactors, recommendation } — blocks or warns before on-chain signing

Agent 3 — Treasury Optimization Agent

  • Trigger: Dashboard load / manual refresh
  • Endpoint: POST /api/treasury
  • Pipeline: Deterministic rule engine (batching, runway, high-risk detection) → Gemini executive summary
  • Output: { recommendations[], executiveSummary }

Agent 4 — Cashflow Predictor

  • Trigger: Analytics page load
  • Endpoint: POST /api/cashflow
  • Output: 90-day cashflow projection, runway days, monthly burn rate

Agent 5 — Autonomous Keeper

  • Trigger: Continuous 30-second loop (standalone process)
  • Logic: Fetches active streams → batch-optimizer.ts computes profitability → executes batchUpdateStreams() if cost-effective
  • Entry point: keeper/intelligent-keeper.ts

Project Structure

Nexora/                               # Repo root
├── README.md
└── nexora-app/
    ├── contracts/                    # Hardhat workspace
    │   ├── contracts/
    │   │   ├── StreamPay.sol         # Nexora Core Payroll Engine
    │   │   ├── StreamFactory.sol     # Nexora Template Engine
    │   │   └── StreamKeeper.sol      # Nexora Keeper Engine
    │   ├── interfaces/
    │   │   └── IStreamPay.sol
    │   ├── deployments/
    │   │   └── addresses.json        # Deployed contract addresses
    │   ├── scripts/
    │   │   ├── deploy.ts
    │   │   ├── deploy.js
    │   │   └── keeper-bot-somnia-testnet.js
    │   ├── hardhat.config.ts
    │   └── package.json
    └── src/                          # Next.js application
        ├── app/
        │   ├── page.tsx                   # Main dashboard
        │   ├── layout.tsx
        │   ├── providers.tsx              # Wagmi + RainbowKit providers
        │   ├── globals.css
        │   ├── create/
        │   │   └── page.tsx               # Stream creation
        │   ├── analytics/
        │   │   ├── page.tsx               # Protocol metrics & charts
        │   │   └── risk/
        │   │       └── page.tsx           # Fraud risk dashboard
        │   ├── templates/
        │   │   └── page.tsx               # Template browser
        │   └── api/
        │       ├── parse-stream/          # NLP parsing agent
        │       ├── check-fraud/           # Fraud detection agent
        │       ├── cashflow/              # Cashflow projection
        │       └── treasury/              # Treasury optimization agent
        ├── components/
        │   ├── NLPStreamInput.tsx
        │   ├── dashboard/
        │   │   ├── AIRecommendationsPanel.tsx
        │   │   ├── IncomingStreams.tsx
        │   │   ├── OutgoingStreams.tsx
        │   │   ├── RiskMeter.tsx
        │   │   ├── RoleSwitcher.tsx
        │   │   ├── RunwayChart.tsx
        │   │   ├── StreamTable.tsx
        │   │   └── TreasuryOverview.tsx
        │   ├── forms/
        │   │   └── CreateStreamForm.tsx
        │   ├── layout/
        │   │   ├── Header.tsx
        │   │   └── StreamCard.tsx
        │   └── ui/
        │       ├── LiveStreamFlow.tsx
        │       ├── badge.tsx
        │       ├── button.tsx
        │       ├── card.tsx
        │       ├── input.tsx
        │       └── label.tsx
        ├── hooks/
        │   ├── useStreamContract.ts
        │   ├── useTemplates.ts
        │   ├── useCashflow.ts
        │   ├── useTheme.ts
        │   └── useTreasuryAgent.ts
        ├── keeper/
        │   ├── intelligent-keeper.ts      # Autonomous keeper agent
        │   └── batch-optimizer.ts         # Profitability engine
        ├── lib/
        │   ├── abis/
        │   │   ├── StreamPay.ts
        │   │   ├── StreamFactory.ts
        │   │   └── StreamKeeper.ts
        │   ├── ai/
        │   │   ├── cashflow-predictor.ts
        │   │   └── treasury-agent.ts
        │   ├── contracts.ts               # Addresses + chain config
        │   ├── stream-fraud-detector.ts   # Heuristics + Gemini fraud check
        │   ├── db.ts
        │   └── utils.ts
        └── types/
            └── index.ts

Setup

1. Frontend

cd nexora-app/src/

# Install dependencies
npm install

Create nexora-app/src/.env.local:

NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
GEMINI_API_KEY=your_gemini_api_key

# Contract addresses — Somnia Testnet
NEXT_PUBLIC_NEXORA_CORE_ADDRESS=0xaa6db326ffc44b999bca1d91b802e99f9d9fcd29
NEXT_PUBLIC_NEXORA_KEEPER_ADDRESS=0x52dd3180486eecf923343b99c91e8a71403113fa
NEXT_PUBLIC_NEXORA_FACTORY_ADDRESS=0x2518849a677efde604e19b1a40843bccdcedb9ec
npm run dev
# Access at http://localhost:3000

2. Autonomous Keeper (Optional)

The keeper is a persistent background worker designed to run on a dedicated server (e.g. EC2, Railway, Heroku worker). It must run separately from the Next.js app because serverless functions cannot maintain long-running loops.

Create nexora-app/src/.env:

KEEPER_PRIVATE_KEY=your_private_key_with_stt_tokens
GEMINI_API_KEY=your_gemini_api_key
NEXORA_CORE_ADDRESS=0xaa6db326ffc44b999bca1d91b802e99f9d9fcd29
SOMNIA_RPC_URL=https://dream-rpc.somnia.network
npm run keeper

3. Deploy Your Own Contracts (Optional)

cd nexora-app/contracts/

# Create .env
PRIVATE_KEY=your_deployer_private_key
SOMNIA_TESTNET_RPC_URL=https://dream-rpc.somnia.network

npx hardhat run scripts/deploy.ts --network somniaTestnet

Update the contract addresses in .env.local after deployment.


Environment Variables

Variable Required Description
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID Yes WalletConnect v2 project ID
GEMINI_API_KEY Yes Google Gemini API key (NLP, fraud, treasury agents)
NEXT_PUBLIC_NEXORA_CORE_ADDRESS Yes Nexora Core Payroll Engine contract address
NEXT_PUBLIC_NEXORA_KEEPER_ADDRESS No Nexora Keeper Engine contract address
NEXT_PUBLIC_NEXORA_FACTORY_ADDRESS No Nexora Template Engine contract address
NEXT_PUBLIC_CHAIN_ID No Defaults to 50312 (Somnia Testnet)
NEXT_PUBLIC_RPC_URL No Defaults to https://dream-rpc.somnia.network
KEEPER_PRIVATE_KEY Keeper only Private key for the keeper agent wallet
NEXORA_CORE_ADDRESS Keeper only Nexora Core contract address (keeper process)
SOMNIA_RPC_URL Keeper only RPC endpoint for the keeper process

Network

Property Value
Chain Somnia Testnet
Chain ID 50312
RPC https://dream-rpc.somnia.network
Explorer https://shannon-explorer.somnia.network
Native currency STT (18 decimals)

Tech Stack

Layer Technologies
Frontend Next.js 14, TypeScript, Tailwind CSS, Framer Motion, Radix UI
Blockchain Wagmi v2, Viem, RainbowKit
Charts Recharts
AI Google Gemini (@google/generative-ai)
Smart contracts Solidity, Hardhat
Chain Somnia Testnet

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors