Skip to main content

Quickstart

Pick Your Path

1. Install SDK

npm install @neus/sdk

2. Create a Client

Initialize the client in your app. Public verifiers do not require API keys.
import { NeusClient } from '@neus/sdk';

const client = new NeusClient({ appId: 'neus-network' });

3. Verify Something

Create a content authorship proof using ownership-basic. This prompts the user’s wallet to sign a request-bound message.
const proof = await client.verify({
  verifier: 'ownership-basic',
  content: 'Hello NEUS',
  wallet: window.ethereum,
});

const proofId = proof.proofId; // Standard SDK field; same receipt ID is used as {qHash} on HTTP paths
Privacy: Default to options: { privacyLevel: 'private', publicDisplay: false } unless you explicitly need public discovery.
  • Storage: Set storeOriginalContent separately from privacy. Private proofs can still store original content when you need owner-only access.
  • Receipt ID: Treat proofId as an opaque receipt identifier. On HTTP routes, the same value appears as {qHash}.

3b. Poll Status (Async Verifiers)

Some verifiers complete instantly; others return 202 and finish asynchronously. Poll until terminal status:
const final = await client.pollProofStatus(proofId, { interval: 3000, timeout: 60000 });
console.log(final.status);

4. Gate Your UI

Use the React component to show content only to verified users.
import { VerifyGate } from '@neus/sdk/widgets';

export default function ProtectedPage() {
  return (
    <VerifyGate
      requiredVerifiers={['nft-ownership']}
      verifierData={{
        'nft-ownership': {
          contractAddress: '0x...',
          tokenId: '1',
          chainId: 1,
        },
      }}
    >
      <div>Access granted.</div>
    </VerifyGate>
  );
}

Hosted Interactive Verifiers (OAuth / ZK)

For ownership-social, ownership-org-oauth, and proof-of-human, VerifyGate launches NEUS hosted checkout.
<VerifyGate
  requiredVerifiers={['ownership-social']}
  onVerified={(result) => {
    console.log('Hosted verification complete', result.proofId);
  }}
>
  <div>Access granted.</div>
</VerifyGate>

4b. Lowest-Friction Auth Path

If you want hosted login plus later API calls without per-request proof-envelope signing:
  1. Redirect users to https://neus.network/verify?intent=login&returnUrl=<your-url>.
  2. If NEUS has enabled hosted auth code exchange for your deployment, your server exchanges the returned auth code at POST /api/v1/auth/code/exchange with your NEUS-issued partner credential.
  3. Use the resulting session/token for later calls.

5. Server-Side Gating (Minimal Eligibility)

For backend/server checks, prefer a gate check (minimal yes/no, no full proof payloads) via GET /api/v1/proofs/check:
const result = await client.gateCheck({
  address: '0x...',
  verifierIds: ['token-holding'],
  contractAddress: '0x...',
  minBalance: '100',
  chainId: 1,
  // Optional: recency requirement for point-in-time verifiers (example: last hour)
  since: Date.now() - 60 * 60 * 1000,
});
Freshness note: for point-in-time verifiers (balances, ownership, risk), always enforce a recency window (since / sinceDays) for high-stakes actions, or create a fresh proof and use the final status.

What’s Next?