On-chain liquidation intelligence with cryptographic proof of AI reasoning.
VeraSignal is a verifiable market intelligence oracle for DeFi. It reads live position data from the Uniswap V3 fork deployed on 0G Chain, classifies wallets as smart money or retail using a TEE-verified AI model via 0G Compute, publishes danger zone signals on-chain via a Solidity oracle contract, and stores historical heatmap snapshots in 0G Storage KV. The frontend provides a real-time liquidation heatmap, a wallet profiler with TEE proof badges, a live on-chain signal feed, and a historical playback scrubber.
| Module | Purpose | SDK |
|---|---|---|
| 0G Compute (TEE) | Wallet classification AI runs inside a Trusted Execution Environment. Each inference returns a ZG-Res-Key header that is verified via broker.inference.processResponse(). The keccak256 of this key becomes the teeProofHash stored on-chain. |
@0glabs/0g-serving-broker |
| 0G Storage KV | Heatmap snapshots are persisted every 5 minutes using the Batcher API. The stream is created automatically on first write. |
@0gfoundation/0g-ts-sdk |
| 0G Chain | VeraSignalOracle.sol is deployed on 0G Chain (chainId 16661). The backend publishes danger zone signals on-chain after every heatmap rebuild. Swap events from 0G Chain's Uniswap V3 fork are used as the live data source. |
ethers v6, chainId 16661 |
┌─────────────────────────────────────────────────────────────┐
│ Frontend (Next.js) │
│ HeatmapChart · PriceChart · WalletLookup+TeeProofBadge │
│ OracleFeed · HistoryPlayback │
└───────────────────┬─────────────────────┬───────────────────┘
│ REST + WebSocket │
┌───────────────────▼─────────────────────▼───────────────────┐
│ Backend (Node.js / TypeScript) │
│ chainPoller.ts ──► liqCalculator.ts ──► store.ts │
│ │ │ │
│ ▼ ▼ │
│ computeClient.ts contractPublisher.ts │
│ (0G Compute TEE) (VeraSignalOracle.sol) │
│ │ │ │
│ └───────────────────┴──► storageWriter.ts │
│ (0G Storage KV) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────▼───────────────────────────────┐
│ 0G Chain (EVM) │
│ Uniswap V3 Pools · VeraSignalOracle.sol │
└─────────────────────────────────────────────────────────────┘
| Network | Address | Explorer |
|---|---|---|
| 0G Mainnet (chainId 16661) | 0x641822A13272b91af7D64245871523fD402156d6 |
View on chainscan |
| 0G Testnet | 0x641822A13272b91af7D64245871523fD402156d6 |
View on chainscan |
Deploy tx (mainnet): 0x226c753c...cfc9bc
- Node.js >= 22.0.0
- pnpm (
npm i -g pnpm) - Foundry (
curl -L https://foundry.paradigm.xyz | bash && foundryup) - Wallet funded with ≥15 0G tokens (3 ledger + 1 per TEE provider + gas)
git clone <repo-url>
cd verasignal
# Backend
cd backend && pnpm install && cd ..
# Frontend
cd frontend && pnpm install && cd ..
# Setup scripts
cd scripts && pnpm install && cd ..cp .env.example .env # or edit .env directlyRun the setup scripts to populate the remaining values:
# Get ZG_PROVIDER_ADDRESS
cd scripts && npx ts-node list-providers.ts
# Get STREAM_ID
npx ts-node create-stream.ts
# Discover live pool addresses (optional; USE_MOCK_DATA=true works without this)
npx ts-node discover-pools.ts
cd ..cd contracts
forge install OpenZeppelin/openzeppelin-contracts
# Testnet
PUBLISHER_ADDRESS=<your-wallet-address> forge script script/Deploy.s.sol \
--rpc-url https://evmrpc-testnet.0g.ai \
--private-key $PRIVATE_KEY \
--broadcast \
--evm-version cancun
# Copy the logged address into .env as ORACLE_CONTRACT_ADDRESScd backend
pnpm run devcd frontend
pnpm run dev
# Open http://localhost:3000| Variable | Description | Required |
|---|---|---|
RPC_URL |
0G Chain RPC endpoint | Yes |
PRIVATE_KEY |
Deployer/publisher wallet key (with 0x prefix) | Yes |
ORACLE_CONTRACT_ADDRESS |
Deployed VeraSignalOracle address | Yes (after deploy) |
STORAGE_INDEXER_URL |
0G Storage indexer URL | Yes |
FLOW_CONTRACT |
0G Storage Flow contract address | Yes |
STREAM_ID |
0G KV stream ID (run create-stream.ts) |
Yes |
ZG_PROVIDER_ADDRESS |
0G Compute TEE provider address | Yes |
PORT |
Backend port (default: 4000) | No |
USE_MOCK_DATA |
Use mock positions instead of live chain data | No |
WALLET_HISTORY_LIMIT |
Max wallet history entries | No |
WALLET_REFRESH_INTERVAL_MS |
Wallet reclassification interval (ms) | No |
SEED_ACCOUNTS |
Comma-separated pre-seeded wallet addresses | No |
| Endpoint | Method | Description |
|---|---|---|
/api/heatmap?market=BTC |
GET | Current heatmap buckets for market |
/api/wallet/:address |
GET | Wallet score + TEE proof hash |
/api/signals?market=BTC&count=20 |
GET | Last N on-chain signals from oracle contract |
/api/history?market=BTC&limit=50 |
GET | Stored snapshot keys from 0G Storage |
/api/health |
GET | Server health + current prices |
- Fetch a signal from
/api/signals— note theteeProofHashfield. - The proof hash is
keccak256(ZG-Res-Key)whereZG-Res-Keyis the response header from the TEE inference call. - To independently verify:
import { ethers } from 'ethers'
import { createZGComputeNetworkBroker } from '@0glabs/0g-serving-broker'
const broker = await createZGComputeNetworkBroker(wallet)
// chatID = the original ZG-Res-Key header value (stored off-chain by the publisher)
const isValid = await broker.inference.processResponse(providerAddress, chatID)
// Verify the hash matches:
const hash = ethers.keccak256(ethers.toUtf8Bytes(chatID))
console.log('Hash matches:', hash === teeProofHash)
console.log('TEE attestation valid:', isValid)# Backend unit tests (Jest) — 37 tests
cd backend && pnpm test
# Frontend E2E tests (Playwright) — 33 tests
# Requires both servers running on :3000 and :4000
cd frontend && pnpm test:e2e- Blocks 1–8 implemented and committed
- Blocks 1–8 implemented and committed
- Contract deployed on 0G mainnet:
0x641822A13272b91af7D64245871523fD402156d6 - 25
SignalPublishedtransactions confirmed on mainnet across BTC, ETH, SOL markets - TEE wallet classification via
@0glabs/0g-serving-broker(local fallback active) - 0G Storage KV snapshots on 5-min interval via
@0gfoundation/0g-ts-sdk - 70 tests passing (37 Jest + 33 Playwright)
- GitHub repo: https://github.com/Dev-In-Crypt/VeraSignal
Sample on-chain signal txs (mainnet):
| Market | Price Level | Tx |
|---|---|---|
| BTC | $71,500 | 0x3cff08a8... |
| BTC | $71,000 | 0xb34cba5f... |
| BTC | $70,000 | 0x332a3685... |
| ETH | $2,140 | 0xc3cdf3d9... |
| ETH | $2,110 | 0xbcda3d9f... |
| SOL | $86 | 0x7c0d902f... |
| SOL | $85 | 0x6938641... |
# Contract tests
cd contracts && forge test -vv
# Backend build
cd backend && pnpm run build
# Frontend build
cd frontend && pnpm run build