Skip to content

YoneCode/FlowState

Repository files navigation

FlowState

Autonomous, real-time, revenue-based credit on Rialo.

A business connects a revenue source and receives a live credit line. The on-chain program reads that revenue itself, sizes the limit, screens for compliance, and keeps the line in sync as revenue changes. There is no oracle to babysit, no keeper bot, and no back office. Underwriting, monitoring, draws, repayments, and freezes all happen inside one program on Rialo.

Why this is only possible on Rialo

Most chains cannot see the outside world. A credit product on them needs an off-chain oracle to push revenue data in and a keeper to trigger the next step. Both are trusted middlemen, and both are where these systems break.

Rialo removes the middlemen:

  • Native web calls (REX). The program fetches a revenue API over HTTPS from inside the chain. Validators perform the call in a TEE, so the result is verifiable and the API key never touches the chain.
  • Reactive transactions. When a REX result returns, it triggers the next step of the workflow automatically. The revenue check chains directly into a sanctions screen with no external scheduler.
  • Confidential execution. Sensitive inputs are encrypted to the REX program, so underwriting can use private data without exposing it on-chain.

The result is a credit engine that is fully autonomous: the program is the oracle, the keeper, and the ledger at once.

How a credit line works

  1. Originate. A borrower opens a line. The program issues a REX call to the revenue endpoint.
  2. Underwrite (REX #1). Validators fetch trailing monthly revenue. The limit is set to a configured share of that revenue. A fraud flag freezes the line.
  3. Comply (REX #2). Approval chains into a second REX call that screens sanctions. A hit freezes the line with reason sanctioned.
  4. Use. The borrower draws and repays natively against the limit. Re-running underwriting resizes the limit as revenue grows, preserving the drawn balance.

Every result is written to the borrower's CreditLine account (a PDA), which the dashboard decodes live.

Verify it on-chain

Everything below is real and deployed on Rialo devnet. Nothing in the dashboard is mocked; every value is decoded from these accounts on each request.

Item Address
Program 6ctqATQJNqNnPUopim57bErJnHxxr4CHwxsHCoHDdvRA
Credit line A (active) 6RJ4qMBvyqtMdNBgC4TqnN1HZknmcQW5KF5Y1PkFottK
Credit line B (frozen, sanctioned) 8qKKAMovdFAQav3pYonsMFr9xSozP83ANRxNTyGJzALs
RPC http://devnet.rialo.io:4100

Read a line account directly from the network:

curl -s http://devnet.rialo.io:4100 \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":[{"version":0,"address":"6RJ4qMBvyqtMdNBgC4TqnN1HZknmcQW5KF5Y1PkFottK","config":{}}]}'

The CreditLine layout (little-endian): [0:32] borrower, [32:40] advance bps, [40:48] credit limit, [48:56] drawn, [56:64] last revenue, [64] status (0 pending, 1 active, 2 frozen), [65] reason (1 fraud, 2 sanctioned).

Architecture

  • program/ - the on-chain program, written in Rialo's Venus DSL. originate issues the REX revenue call and chains into the sanctions screen; native instructions (init_line, draw, repay) operate on the per-borrower CreditLine PDA.
  • frontend/ - the live dashboard (React + Vite). Reads decoded portfolio state and lets a borrower connect with email (Privy embedded Ed25519 wallet) to airdrop, create a line, run underwriting, draw, and repay with their own signature.
  • landing/ - the marketing site (Astro).
  • server/ - a zero-dependency Node server that decodes on-chain state for the portfolio API and proxies signed transactions to the RPC.
  • cloudflare/ - Pages Functions for the production deploy: the same on-chain reader plus a revenue oracle backed by real Stripe data.
  • invoke-test/, client/, generated-client/ - Rust clients and the generated ABI client used to deploy and exercise the program.

Tech stack

Rialo Venus DSL and rialo-s-program (on-chain), @rialo/ts-cdk and @rialo/wallet-standard (browser signing), Privy (email to embedded wallet), React, Vite, Astro, Node, and Cloudflare Pages.

Local development

# dashboard
cd frontend && npm install && npm run build

# landing
cd landing && npm install && npm run build

# serve both + the on-chain API
node server/server.mjs

The program is built and deployed with the Rialo toolchain; see program/README.md.

Deploy

The landing page, dashboard, and the Stripe-backed revenue oracle deploy to Cloudflare Pages. See cloudflare/README.md for the exact build settings, the Pages Functions, and the secret handling for the revenue API key.

Security

  • No private keys, .env files, or API keys are committed. Revenue API keys live as Cloudflare Pages secrets and are read only inside the REX call.
  • Borrower draws and repays are signed client-side by the borrower's own wallet.
  • The program enforces ownership: a draw only succeeds for the account that owns the line.

About

Autonomous, real-time business credit , underwritten, monitored, and settled entirely on-chain. No oracles to babysit, no back office, no waiting weeks for a decision.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors