Skip to main content

Setup

Warning

This documentation refers to a state of our SDK which is currently in alpha. Documentation and sdk functions are subject to change pending developer feedback.

This page covers how to get quickly up-and-running with the Node Identity SDK

Installation

via yarn

yarn add @node-fi/identity@alpha

via npm

npm install @node-fi/identity@alpha

Get started

To use the identity sdk, simply import and create a new instance of NodeIdentityKit

Parameters

NameTypeDefaultDescription
_apiKeystringNode API Key
trustedAttestorsstring[][]Array of trusted attestor addresses
mergeStrategy"latest" | "earliest""latest"Strategy to use when merging multiple attestations. Use "latest" to use the most recent attestation, or "earliest" to use the earliest attestation.

The only required paramter is apiKey, which will be the same api key used elsewhere in the Node stack.

As outlined in about, you can specify additional attestors to trust. By default Node is the trusted attestors. Attestors will be assigned a trust score in the order given, such that Attestor i has a greater trust score than Attestor i + 1. Node attestor, unless explicityly listed, will be assigned the lowest trust score, such that all other listed attestors are prioritized first.

In some cases, an identifier may link to multiple addresses. To handle this case, there is an optional mergeStrategy parameter. A strategy of "latest" will put greater trust in the most recent attestation from the most trusted attestor. "earliest" will put greater trust in the first attestation from the most trusted attestor.

Example

import { NodeIdentityKit, Attestor } from "@node-fi/identity";
import { getApiKey, TokenAmount, Wallet } from "@node-fi/sdk-core";

const TRUSTED_ATTESTORS = ["node", "valora", "kaala"];

const kit = new NodeIdentityKit(
getApiKey(),
TRUSTED_ATTESTORS.flatMap((name) => Attestor.findBy("name", name).issuers)
);

const sendToPhoneNumber = async (
from: Wallet,
amount: TokenAmount,
recipientPhoneNumber: string
) => {
const { address } = await kit.lookup(recipientPhoneNumber);
return from.send(amount, address);
};