Skip to main content

JavaScript SDK

JavaScript client (and optional widgets) for the NEUS Network verification API.

Install

npm install @neus/sdk

Create a proof (browser wallet flow)

This path requests a wallet signature in the browser and submits the verification request:
import { NeusClient } from '@neus/sdk';

const client = new NeusClient({ apiUrl: 'https://api.neus.network' });

const res = await client.verify({
  verifier: 'ownership-basic',
  content: 'Hello NEUS'
});

// Proof ID (standard SDK field). HTTP paths may carry the same receipt as {qHash}.
const proofId = res.proofId;
const status = await client.getStatus(proofId);

Client configuration

const client = new NeusClient({
  // Optional: API base URL (default: https://api.neus.network)
  apiUrl: 'https://api.neus.network',
  // Optional: public app attribution ID (non-secret)
  appId: 'neus-network',
  // Optional: request timeout (ms)
  timeout: 30000,
});

Create a proof (server / manual signing)

If you need manual or server-side signing, ask the API for the exact string first:
import { standardizeVerificationRequest, signMessage } from '@neus/sdk';

const provider = window.ethereum;
const walletAddress = '0x1111111111111111111111111111111111111111';
const signedTimestamp = Date.now();
const body = {
  verifierIds: ['ownership-basic'],
  data: {
    owner: walletAddress,
    content: 'Hello NEUS',
    reference: { type: 'url', id: 'https://example.com' }
  },
  walletAddress,
  signedTimestamp,
  chainId: 84532,
};

const standardized = await standardizeVerificationRequest(body, {
  apiUrl: 'https://api.neus.network',
});

const signature = await signMessage({
  provider,
  walletAddress,
  message: standardized.signerString
});

const res = await client.verify({
  ...body,
  signature,
  options: { privacyLevel: 'private' }
});
In the NEUS Hub (first-party UI), matching authenticated sessions may allow session-first proof creation without a repeat proof-envelope signature. The SDK examples here document the generic integrator path.

What verifiers are available?

Use the API directly:
GET /api/v1/verification/verifiers

App attribution (appId)

Set appId on the client to attribute usage and analytics to your app. appId is a public identifier, not a secret.
const client = new NeusClient({
  apiUrl: 'https://api.neus.network',
  appId: 'acme-web',
});

Hosted checkout URL builder

Use getHostedCheckoutUrl for a single typed entry point:
import { getHostedCheckoutUrl } from '@neus/sdk';

const url = getHostedCheckoutUrl({
  gateId: 'my-gate',
  returnUrl: 'https://myapp.com/callback',
  verifiers: ['ownership-social'],
  intent: 'login',
});
// => https://neus.network/verify?gateId=my-gate&returnUrl=...&verifiers=...
For production server-side gating, prefer the minimal public endpoint:
const res = await client.gateCheck({
  address: 'YOUR_WALLET_OR_DID',
  verifierIds: ['token-holding'],
  contractAddress: '0x...',
  minBalance: '100',
  chainId: 8453,
  // Optional: require a recent proof for point-in-time verifiers
  since: Date.now() - 60 * 60 * 1000
});

if (!res.data?.eligible) {
  throw new Error('Access denied');
}
gateCheck evaluates existing public/discoverable proofs. For strict real-time decisions, create a new proof and use the final status.

Resilience & Polling

The SDK is designed for production stability:
  • Automatic Backoff: pollProofStatus() automatically detects rate limiting (429) and applies jittered exponential backoff
  • Wallet Identification: Automatically attaches headers for higher reliability behind shared IPs

Private proof operations

// Private proof by proof receipt ID
const privateData = await client.getPrivateStatus(proofId, window.ethereum);

// Private proofs by wallet/DID (requires owner signature)
const privateProofs = await client.getPrivateProofsByWallet(
  'YOUR_WALLET_OR_DID',
  { limit: 50, offset: 0 },
  window.ethereum
);

// Revoke your proof
await client.revokeOwnProof(proofId, window.ethereum);

React widgets

For UI gating, see Widgets.
import { VerifyGate, ProofBadge } from '@neus/sdk/widgets';