Inicio Rápido
Get up and running with Web of Trust in just a few minutes.
Client-side (with the SDK)
For client-side applications, use the SDK's Web of Trust module. Install nostr-wot-sdk and query hop distance right in the browser.
1. Install
2. Query Trust Distance
import { WoT } from "@nostr-wot/wot";
const wot = new WoT({ rootPubkey: "hex-your-pubkey", maxHops: 2 });
// Get hop distance to a target pubkey
const result = await wot.getDistance("hex-target-pubkey");
if (result && result.hops <= 2) {
// Within web of trust
console.log(`Trusted: ${result.hops} hops away`);
} else {
// Outside web of trust or not connected
console.log("Not in your web of trust");
}Tip: Hop values: 0 = yourself, 1 = direct follow, 2 = follow of follow, null = not connected. If the WoT extension is installed, the module answers queries from its locally-cached follow graph automatically.
Servidor (con API Oracle)
For server-side applications, use the Oracle REST API. No extension required.
Using fetch
const response = await fetch(
`https://wot-oracle.mappingbitcoin.com/distance?` +
`from=${fromPubkey}&to=${toPubkey}`
);
const data = await response.json();
console.log(`Distance: ${data.distance}`);
console.log(`Paths: ${data.paths}`);
console.log(`Mutual follow: ${data.mutual}`);Using cURL
Using the SDK in React
For React apps, wrap your tree in <NostrSdkProvider> — it wires up the data layer (profiles, notes, threads, engagement) and enables the Web of Trust module when you opt in. Trust hooks are then available anywhere.
import { NostrSdkProvider, useTrustScore } from "nostr-wot-sdk/react";
function App() {
return (
<NostrSdkProvider
relays={["wss://relay.damus.io", "wss://nos.lol"]}
wot={{ enabled: true, options: { maxHops: 2 } }}
>
<Feed />
</NostrSdkProvider>
);
}
function TrustBadge({ pubkey }: { pubkey: string }) {
const score = useTrustScore(pubkey); // 0..1 or null
return score !== null ? <span>Trusted</span> : null;
}Compilar desde el Código Fuente
Clona el repositorio y compila localmente para desarrollo o para verificar el código.
Ve a chrome://extensions, activa Modo desarrollador, haz clic en Cargar descomprimida y selecciona la carpeta dist/.