@holonym-foundation/human-id-sdk
v0.2.0
Published
SDK for embedding Human ID
Readme
@holonym-foundation/human-id-sdk
A TypeScript SDK for integrating Human ID private verification flows with SBTs into your app.
Installation
npm install @holonym-foundation/human-id-sdkQuick Start
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.
import { setOptimismRpcUrl } from '@holonym-foundation/human-id-sdk'
setOptimismRpcUrl('YOUR_OPTIMISM_RPC_URL')Query functions:
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.
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.
npx humanid --help