🏛️ Case Study: SovereignTrust
SovereignTrust is a legal trust management platform built entirely on OASIS WEB4 and WEB6. Users authenticate via their OASIS Avatar, store trust deeds as encrypted Holons, pay via Stripe, and get legal guidance from Leela — an AI assistant powered by FAHRN Debate mode across three AI providers. This case study walks through every integration step-by-step.
Tech stack
- Frontend: Vanilla JS, html2canvas, pdf-lib, docx
- OASIS WEB4: Avatar SSO, Holon storage (trust deeds), HyperDrive encryption, Karma rewards
- OASIS WEB6: Leela AI assistant, FAHRN Debate mode, Holonic Memory (user + group)
- Payments: Stripe Checkout + webhooks
- npm:
@oasisomniverse/web4-api,@oasisomniverse/web6-api
Architecture Overview
Browser
│
├─ Avatar login (WEB4) ─────────────────► OASIS ONODE API
│ ├─ Avatar SSO
│ ├─ JWT issued
│ └─ Karma score loaded
│
├─ Trust deed creation
│ ├─ docx generation (client-side)
│ ├─ pdf-lib rendering
│ └─ Holon save (WEB4 HyperDrive) ──────► Encrypted across providers
│
├─ Stripe checkout ────────────────────────► Stripe API → webhook → unlock features
│
└─ Leela AI chat (WEB6 FAHRN Debate) ─────► 3 AI providers debate → judge synthesis
└─ Holonic Memory auto-injected
Step 1 — Avatar SSO
SovereignTrust uses the OASIS Avatar as the single identity — no separate auth system needed.
import { OasisWeb4Client } from '@oasisomniverse/web4-api'; const oasis4 = new OasisWeb4Client({ baseUrl: 'https://api.web4.oasisomniverse.one' }); async function login(email, password) { const { result, isError, message } = await oasis4.avatar.authenticate({ email, password }); if (isError) throw new Error(message); oasis4.auth.setToken(result.token); localStorage.setItem('oasis_token', result.token); localStorage.setItem('avatar_id', result.avatar.id); return result.avatar; } // On page load — restore session const token = localStorage.getItem('oasis_token'); if (token) oasis4.auth.setToken(token);
See Module 2: Avatar & Identity for full auth patterns.
Step 2 — Storing Trust Deeds as Holons
Each trust deed is a Holon — a structured, encrypted, provider-agnostic data object stored via HyperDrive.
async function saveTrustDeed(deed) { const { result } = await oasis4.data.saveHolon({ holonType: 'TrustDeed', name: deed.trustName, description: deed.description, customData: { settlor: deed.settlor, trustees: deed.trustees, beneficiaries: deed.beneficiaries, jurisdiction: deed.jurisdiction, trustType: deed.trustType, // 'Discretionary' | 'Fixed' | 'Bare' createdAt: new Date().toISOString(), }, isEncrypted: true, providerType: 'HoloOASIS', // primary; HyperDrive handles failover }); return result.id; }
See Module 5: Data & Holons and Module 9: HyperDrive Storage.
Step 3 — PDF & DOCX Generation
import { PDFDocument, StandardFonts } from 'pdf-lib'; import { Document, Packer, Paragraph } from 'docx'; async function generateTrustPDF(deed) { const pdfDoc = await PDFDocument.create(); const font = await pdfDoc.embedFont(StandardFonts.Helvetica); const page = pdfDoc.addPage(); page.drawText(`Trust Deed: ${deed.trustName}`, { x: 50, y: 750, size: 18, font }); // ... full deed content ... const pdfBytes = await pdfDoc.save(); // Upload PDF to OASIS file storage await oasis4.files.upload({ fileName: `${deed.trustName}.pdf`, data: pdfBytes, holonId: deed.holonId, // attach to the trust deed holon isPrivate: true, }); }
Step 4 — Stripe Payment Integration
async function createCheckoutSession(avatarId, planId) { // Your backend creates a Stripe session and stores avatarId in metadata const res = await fetch('/api/stripe/checkout', { method: 'POST', body: JSON.stringify({ avatarId, planId }), headers: { 'Content-Type': 'application/json' }, }); const { url } = await res.json(); window.location.href = url; } // Webhook handler (server-side): on payment.succeeded // → save subscription holon via WEB4, award karma to avatar async function handleStripeWebhook(event) { if (event.type === 'checkout.session.completed') { const { avatarId, planId } = event.data.object.metadata; await oasis4.karma.award({ avatarId, amount: 500, reason: 'SovereignTrust subscription' }); await oasis4.data.saveHolon({ holonType: 'Subscription', customData: { planId, status: 'active' }}); } }
Step 5 — Leela: AI Legal Assistant
Leela uses FAHRN Debate mode — three AI providers argue each legal question, and a judge agent synthesises the final answer. Holonic Memory injects the user's trust portfolio automatically.
import { OasisWeb6Client } from '@oasisomniverse/web6-api'; const ai = new OasisWeb6Client({ baseUrl: 'https://api.web4.oasisomniverse.one' }); ai.auth.setToken(oasis4.auth.getToken()); async function askLeela(question, avatarId, sessionId) { const { result } = await ai.fahrn.run({ mode: 'Debate', rounds: 2, agents: [ { name: 'LegalAdvocate', provider: 'openai', model: 'gpt-4o', systemPrompt: 'You are a UK trust law specialist. Give the strongest legal interpretation.' }, { name: 'RiskAdvisor', provider: 'anthropic', model: 'claude-3-5-sonnet', systemPrompt: 'You identify risks and edge cases in trust structures.' }, { name: 'TaxCounsel', provider: 'google', model: 'gemini-pro', systemPrompt: 'You focus on HMRC and IHT implications of trust decisions.' }, ], judge: { provider: 'anthropic', model: 'claude-3-5-sonnet', systemPrompt: 'You are Leela, a helpful and precise UK trust law assistant. Synthesise the best answer.', }, input: question, memoryContext: { avatarId, sessionId, injectLevels: ['Session', 'User', 'Group'], topK: 6 }, }); return result.judgeVerdict; }
See Module 16: FAHRN and Module 17: Holonic Memory for full details.
Step 6 — Karma Rewards
// Award karma when user completes a trust deed — unlocks higher AI tiers await oasis4.karma.award({ avatarId, amount: 250, reason: 'Trust deed created', karmaType: 'LegalAction', });
See Module 3: Karma & Reputation.
Browse the full SovereignTrust source at github.com/NextGenSoftwareUK/OASIS/tree/master/trust ↗