open-index/open-npm huggingface dataset:
npm package: @holonym-foundation/human-id-sdk
Description: SDK for embedding Human ID
Latest version: 0.2.1

# @holonym-foundation/human-id-sdk

A TypeScript SDK for integrating Human ID private verification flows with SBTs into your app.

## Installation

```bash
npm install @holonym-foundation/human-id-sdk
```

## Quick Start

```typescript
import { initHumanID } from '@holonym-foundation/human-id-sdk'

// Initialize the SDK. This should be done client-side (e.g., in a useEffect) because it relies on the window object
const humanID = initHumanID()

// Request a KYC SBT
const result = await humanID.requestSBT('kyc')
console.log('SBT recipient:', result?.recipient)
```

### Query SBTs

First, to make SBT queries, you must provide an RPC URL for Optimism.

```typescript
import { setOptimismRpcUrl } from '@holonym-foundation/human-id-sdk'

setOptimismRpcUrl('YOUR_OPTIMISM_RPC_URL')
```

Query functions:

```typescript
import {
  getPhoneSBTByAddress,
  getKycSBTByAddress,
  uncheckedGetMinimalPhoneSBTByAddress,
  uncheckedGetMinimalKycSBTByAddress
} from '@holonym-foundation/human-id-sdk'

const phoneSbt = await getPhoneSBTByAddress(address)
const kycSbt = await getKycSBTByAddress(address)

const minimalPhoneSbt = await uncheckedGetMinimalPhoneSBTByAddress(address)
const minimalKycSbt = await uncheckedGetMinimalKycSBTByAddress(address)
```

## Using Prepaid Payment Secrets

If your organization has prepaid for SBT mints using the Human ID Credits system, you can pass a payment secret to `requestSBT` to use a prepaid credit instead of requiring the user to pay.

```typescript
import { initHumanID } from '@holonym-foundation/human-id-sdk'

const humanID = initHumanID()

// Request an SBT using a prepaid payment secret
const result = await humanID.requestSBT('kyc', {
  paymentConfig: {
    paymentSecret: 'your-payment-secret-here', // 64-character hex string
    paymentSecretChainId: 10 // Chain ID where the payment was made (e.g., 10 for Optimism)
  }
})

console.log('SBT recipient:', result?.recipient)
```

## Binary

The SDK includes a binary with utilities for managing payment secrets.

After installing the SDK, you can invoke it to see the available commands.

```bash
npx humanid --help
```