Verify humanity and request reputation scores in your Next.js or Node.js app.
npm install bringidVerify humanity and request reputation scores in your Next.js or Node.js app.
``bash`
npm install bringid
`ts
import { BringID } from "bringid";
const bringid = new BringID();
// Get a reputation score (0-100) — works immediately
const { score } = await bringid.getAddressScore("0x...");
// Verify humanity and get proofs — requires modal setup (see below)
const { proofs, points } = await bringid.verifyHumanity();
// Verify proofs and get points breakdown — works immediately
const { verified, points } = await bringid.verifyProofs({ proofs: [ ... ]})
`
> Note: getAddressScore and verifyProofs works out of the box. verifyHumanity requires the modal provider — see Setup below.
For React/Next.js:
- Next.js 13+ (App Router)
- React 18+
- Wallet provider (wagmi, ethers, etc.)
For Node.js:
- Node.js 16+
Create a shared instance to use across your app:
`ts
// lib/bringid.ts
import { BringID } from "bringid";
export const bringid = new BringID();
// will return a BringID instance ready for production
`
The verifyHumanity method requires a modal. Render it once at the root of your app:
`tsx
// app/providers/BringIDProvider.tsx
"use client";
import { BringIDModal } from "bringid/react";
import { useAccount, useWalletClient } from "wagmi";
export function BringIDProvider({ children }: { children: React.ReactNode }) {
const { address } = useAccount();
const { data: walletClient } = useWalletClient();
return (
<>
{walletClient && (
generateSignature={(message) => walletClient.signMessage({ message })}
iframeOnLoad={() => console.log("BringID ready")}
/>
)}
{children}
>
);
}
`
`tsx
// app/layout.tsx
import { BringIDProvider } from "./providers/BringIDProvider";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
API
$3
Returns a reputation score for any address. No wallet connection required.
`ts
const { score } = await bringid.getAddressScore("0x...");
`Returns:
-
score — number between 0 and 100$3
Verifies proofs and returns verification status with points breakdown.
`ts
const { verified, points } = await bringid.verifyProofs({ proofs: [ ... ] });
// verified: true/false
// points: { total: 15, groups: [{ credential_group_id: "16", points: 10 }, ...] }const provider = new JsonRpcProvider('https://sepolia.base.org');
const { verified, points } = await bringid.verifyProofs({ proofs: [ ... ], provider });
// it is possible to use a custom JSONRpcProvider for a proofs validity check
`Returns:
-
verified — boolean indicating if proofs are valid
- points — object containing:
- total — total points across all credential groups
- groups — array of { credential_group_id, points } for each proof$3
Opens the verification modal and returns proofs. Requires the modal provider to be mounted.
`ts
const { proofs, points } = await bringid.verifyHumanity();// With custom scope
const { proofs, points } = await bringid.verifyHumanity({
scope: "0x...",
});
// With minumum points requirement. If
minPoints not presented any amount of points above 0 is acceptable
const { proofs, points } = await bringid.verifyHumanity({
minPoints: 10,
});
`Returns:
-
proofs — Array of semaphore proofs
- points — Humanity points earnedConfiguration
$3
Use
mode="dev" on the modal for testing:`tsx
mode="dev"
address={address}
generateSignature={(message) => walletClient.signMessage({ message })}
/>
`Also it should be used for BringID instance
`tsx
const bringid = new BringID({ mode: "dev" });
`> Note: Production mode is enabled by default. Only use
dev mode during development.Example
`tsx
"use client";import { useState } from "react";
import { bringid } from "@/lib/bringid";
export function VerifyButton() {
const [points, setPoints] = useState(null);
const handleVerify = async () => {
try {
const { points, proofs } = await bringid.verifyHumanity();
setPoints(points);
} catch (err) {
console.error("Verification failed:", err);
}
};
return (
{points !== null && Points: {points}
}
);
}
`Troubleshooting
Modal doesn't open
- Ensure
BringIDProvider is in your layout
- Ensure the component calling verifyHumanity has "use client"`Score returns undefined
- Verify the address format is correct (checksummed)
MIT