SDK reference
Package: @keyringnetwork/keyring-connect-sdk. All methods are static on the
KeyringConnect class. The package also re-exports everything from
@keyringnetwork/contracts-abi (chain constants, ABIs, and the deployment
artifact getters used in contract addresses).
Methods
launchExtension
static async launchExtension(data: ExtensionSDKConfig): Promise<void>Launches the extension with the given configuration, or redirects to the installation page when the extension is absent. Throws on invalid configuration and on communication failures; the full error catalogue is in error handling.
isKeyringConnectInstalled
static async isKeyringConnectInstalled(): Promise<boolean>True when the extension responds with its manifest within two seconds. Never throws.
getExtensionState
static async getExtensionState(): Promise<ExtensionState | null>Reads the current extension state. Resolves to null when the extension is
unavailable or unresponsive. Never throws.
subscribeToExtensionState
static subscribeToExtensionState(
callback: (state: ExtensionState | null) => void
): () => voidPolls the extension every three seconds and invokes the callback on change
(deep comparison). The callback receives null when the extension becomes
unavailable. Returns an unsubscribe function that stops polling.
Types
ExtensionSDKConfig
type ExtensionSDKConfig = {
name: string; // client name
app_url: string; // client app URL the extension communicates with
logo_url: string; // client logo URL
policy_id: number; // on-chain policy ID
credential_config: {
chain_id: number;
wallet_address: string;
};
};ExtensionState
interface ExtensionState {
status: ExtensionStatus;
manifest?: any;
error?: string;
user?: User;
tlsn_proof?: string;
credentialData?: CredentialData;
}ExtensionStatus
type ExtensionStatus =
| "idle"
| "mounted"
| "proving"
| "prove_error"
| "prove_success"
| "error";User
type User = {
attestation_status: AttestationStatus; // off-chain status
credential_status: CredentialStatus; // on-chain status
wallet_address: string;
user_id: string;
entity_id: string;
};AttestationStatus
type AttestationStatus =
| "onboarding_required"
| "onboarding_pending"
| "attestation_ready"
| "non_compliant";CredentialStatus
type CredentialStatus = "expired" | "valid" | "none";CredentialData
The parameters of the on-chain credential, matching the arguments of
KeyringCore.createCredential:
interface CredentialData {
trader: `0x${string}`;
policyId: number;
chainId: number;
validUntil: number;
cost: number;
key: string;
signature: string;
backdoor: string;
}