Chat and stablecoin payments, inside your own web product — added with one script tag.
Your members talk and settle in USDT or USDC without leaving your site, and every payment
they agree to share is recorded in your own system as it happens — not in someone else's app.
The Messages button in the corner is the real widget running in demo mode — try it.
The whole integration, on one screen
On the left, a platform like yours. Switch to After to see exactly what the widget adds.
On the right, the real code that adds it. The outlined, numbered parts on the left match the
numbered lines in the code — hover or focus either side to light up the other.
Your page
Meridian OTC
DeskDealsLedger
Counterparties
Signed in · Meridian desk
Lagos FX DeskKYB ✓on chat
Kano Imports LtdKYB ✓on chat
Trade ledger
Counterparty
Amount
Source
Lagos FX Desk
2,500 USDT
from chat
Kano Imports Ltd
2,000 USDT
Manual entry
Adaeze O.
400 USDT
Screenshot
Meridian OTC · Lagos FX Desk
Agreed — 2,500 USDT for the lot.
Sending now.
Transfer · USDT
2,500.00
BNB Smart Chain · ref D-1042
What you add
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EXTRA SAFE widget — plain HTML example</title>
<style>
body { font: 15px/1.5 system-ui, sans-serif; max-width: 640px; margin: 40px auto; padding: 0 16px; }
button { font: inherit; padding: 8px 14px; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
</style>
</head>
<body>
<h1>Counterparties</h1>
<p>This page runs the widget in <b>demo mode</b> (no backend configured).</p>
<!-- Your own buttons, wired declaratively — no JS glue needed.
The address here is a demo placeholder. -->
<div class="row">
<span>Lagos FX Desk</span>
<button data-extrasafe-message="0x71C7656EC7ab88b098defB751B7401B5f6d8976F">Message</button>
<button
data-extrasafe-pay="0x71C7656EC7ab88b098defB751B7401B5f6d8976F"
data-amount="2500"
data-token="USDT"
data-network="BNB Smart Chain"
data-reference="D-1042"
>
Pay 2,500 USDT
</button>
</div>
<!-- Open the panel from your own nav, with launcher hidden. -->
<div class="row">
<button data-extrasafe-open>Open Messages</button>
</div>
<!-- The whole client-side integration: one script tag + init().
Swap the src for /widget.js during local development. -->
<script src="https://widget.extrasafe.net/v0/widget.js"></script>
<script>
ExtraSafe.init({
host: 'example',
brand: { name: 'Example OTC', accentColor: '#0b5fff', theme: 'light' },
user: { platformUserId: 'u_42', displayName: 'You' },
members: [
{
platformUserId: 'u_lagos',
displayName: 'Lagos FX Desk',
address: '0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
kyc: { status: 'verified', label: 'KYB' },
},
],
onTransfer: function (e) {
// In production: POST e to your server and verify e.txHash on-chain.
console.log('[example] transfer', e);
},
onError: function (err) {
console.warn('[example] error', err.code, err.message);
},
});
</script>
</body>
</html>
App.tsx
import { ExtraSafeProvider, useExtraSafe } from './useExtraSafe';
// Runnable sketch: wrap your app in <ExtraSafeProvider> and drive the widget
// from your own buttons. Runs in demo mode (no endpoints configured).
const MEMBERS = [
{
platformUserId: 'u_lagos',
displayName: 'Lagos FX Desk',
address: '0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
kyc: { status: 'verified' as const, label: 'KYB' },
},
];
function Counterparty() {
const es = useExtraSafe();
const addr = MEMBERS[0].address;
return (
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<span>{MEMBERS[0].displayName}</span>
<button onClick={() => es?.openChatWith(addr)}>Message</button>
<button
onClick={() =>
es?.startTransferTo(addr, {
amount: '2500',
token: 'USDT',
network: 'BNB Smart Chain',
reference: 'D-1042',
})
}
>
Pay 2,500 USDT
</button>
</div>
);
}
export default function App() {
return (
<ExtraSafeProvider
config={{
host: 'example',
brand: { name: 'Example OTC', accentColor: '#0b5fff' },
user: { platformUserId: 'u_42', displayName: 'You' },
members: MEMBERS,
onTransfer: (e) => console.log('[example] transfer', e),
}}
>
<h1>Counterparties</h1>
<Counterparty />
</ExtraSafeProvider>
);
}
useExtraSafe.tsx
import {
createContext,
useContext,
useEffect,
useRef,
useState,
type ReactNode,
} from 'react';
import type { ExtraSafeApi, HostConfig } from '../../extrasafe-widget';
// Minimal React integration for the EXTRA SAFE widget: load widget.js once,
// init once, re-init when the signed-in user changes, and clean up on unmount.
// Drop <ExtraSafeProvider config={...}> near your app root and read the handle
// with useExtraSafe().
const WIDGET_SRC = 'https://widget.extrasafe.net/v0/widget.js';
const Ctx = createContext<ExtraSafeApi | null>(null);
function loadScript(src: string): Promise<void> {
return new Promise((resolve, reject) => {
if (window.ExtraSafe && typeof window.ExtraSafe.init === 'function') return resolve();
const existing = document.querySelector<HTMLScriptElement>(`script[src="${src}"]`);
if (existing) {
existing.addEventListener('load', () => resolve(), { once: true });
existing.addEventListener('error', () => reject(new Error('load failed')), { once: true });
return;
}
const s = document.createElement('script');
s.src = src;
s.async = true;
s.onload = () => resolve();
s.onerror = () => reject(new Error('load failed'));
document.head.appendChild(s);
});
}
export function ExtraSafeProvider({
config,
children,
}: {
config: HostConfig;
children: ReactNode;
}) {
const [api, setApi] = useState<ExtraSafeApi | null>(null);
const userKey = config.user?.platformUserId ?? '';
const configRef = useRef(config);
configRef.current = config;
useEffect(() => {
let cancelled = false;
loadScript(WIDGET_SRC)
.then(() => {
if (cancelled) return;
setApi(window.ExtraSafe.init(configRef.current));
})
.catch((e) => console.warn('[extrasafe] script load failed', e));
return () => {
cancelled = true;
window.ExtraSafe?.destroy();
};
// Re-init when the signed-in host user changes (fresh wallet namespace).
}, [userKey]);
return <Ctx.Provider value={api}>{children}</Ctx.Provider>;
}
/** The widget handle, or null until widget.js has loaded and init() has run. */
export function useExtraSafe(): ExtraSafeApi | null {
return useContext(Ctx);
}
ExtraSafeWidget.tsx
'use client';
import Script from 'next/script';
import { useEffect, useRef } from 'react';
import type { HostConfig } from '../../extrasafe-widget';
// Next.js App Router client component. Loads widget.js with next/script and
// (re)initialises when the signed-in user changes. Mount it once in a client
// boundary (e.g. a layout). Runs in demo mode unless you pass `endpoints`.
const WIDGET_SRC = 'https://widget.extrasafe.net/v0/widget.js';
export function ExtraSafeWidget({ config }: { config: HostConfig }) {
const ready = useRef(false);
const configRef = useRef(config);
configRef.current = config;
const userKey = config.user?.platformUserId ?? '';
useEffect(() => {
if (ready.current && window.ExtraSafe) {
window.ExtraSafe.init(configRef.current); // re-init on user change
}
return () => {
window.ExtraSafe?.destroy();
};
}, [userKey]);
return (
<Script
src={WIDGET_SRC}
strategy="afterInteractive"
onLoad={() => {
ready.current = true;
window.ExtraSafe.init(configRef.current);
}}
/>
);
}
page.tsx
'use client';
import { ExtraSafeWidget } from './ExtraSafeWidget';
// Example App Router page. In a real app, mount <ExtraSafeWidget> once in a
// client layout and read the signed-in user from your auth/session. Buttons use
// the declarative attributes, so no imperative glue is needed here.
const PEER = '0x71C7656EC7ab88b098defB751B7401B5f6d8976F';
export default function Page() {
return (
<main style={{ maxWidth: 640, margin: '40px auto', fontFamily: 'system-ui' }}>
<h1>Counterparties</h1>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<span>Lagos FX Desk</span>
<button data-extrasafe-message={PEER}>Message</button>
<button
data-extrasafe-pay={PEER}
data-amount="2500"
data-token="USDT"
data-network="BNB Smart Chain"
data-reference="D-1042"
>
Pay 2,500 USDT
</button>
</div>
<ExtraSafeWidget
config={{
host: 'example',
brand: { name: 'Example OTC', accentColor: '#0b5fff' },
user: { platformUserId: 'u_42', displayName: 'You' },
members: [
{
platformUserId: 'u_lagos',
displayName: 'Lagos FX Desk',
address: PEER,
kyc: { status: 'verified', label: 'KYB' },
},
],
onTransfer: (e) => console.log('[example] transfer', e),
}}
/>
</main>
);
}
This is the whole client-side integration.
① The <script> tag loads the widget.
②brand sets the panel header and accent colour.
③user and members — the signed-in member and your suggested counterparties, with their KYC chip.
④data-extrasafe-message / -pay on your own buttons open the chat or a pre-filled payment.
⑤onTransfer gives you the new ledger row.
What happens when a member pays
1
Agree the trade in chat.
2
2,500USDTfrom deal D-1042
Tap Pay — amount, token and reference pre-filled from the deal.