Sailos

NodeJS

Installation

bun i @omnid/sdk

This SDK is compatible for the Web, Server & React-Native based environments. Here is a tutorial on Intergating this on the Web.

You can set it up using,

import { Omnid } from "@omnid/sdk";
let omnid = new Omnid();

Authentication

relayLoginProof

Example,

let relayResponse = await omnid.auth.relayLoginProof(
  [
    proof.a[0],
    proof.a[1],
    proof.b[0][1],
    proof.b[0][0],
    proof.b[1][1],
    proof.b[1][0],
    proof.c[0],
    proof.c[1],
  ],
  publicSignals
);

Reference,

relayLoginProof = async (
  proof: Array<string>,
  publicSignals: Array<string>,
  relayEndpoint: string = "https://alchemy.omnid.io/relay/login",
): Promise<RelayResponse>

exchangeForJwt

Example,

let body = await req.json() as Omit<TokenExchangeRequest, 'appSecretKey'>;
let omnid = new Omnid();
 
const respData = await omnid.auth.exchangeForJwt({
    ...body,
    appSecretKey: process.env['OMNID_SIGNIN_SECRET_KEY'] as string
});

Reference,

exchangeForJwt = async (
  details: TokenExchangeRequest,
  vaultEndpoint: string = "https://vault.omnid.io",
): Promise<TokenExchangeResponse>

Function Cloud

Function Cloud hosts large circuit assets and has a fast proof execution environment supporting multiple backends. Learn more about it

getCircuitFiles

Example,

const sig = omnid.fc.getCircuitFiles('VerifySignature10');
const { downloaded, downloadProgress, makeProof } = useProof(sig);

Reference,

getCircuitFiles = (
  proofId: supportedProofIds,
  cdn = ''
): circuitFileDetails

makeProof

Example,

const { proof, publicSignals } = await makeProof('rsa', []);

Reference,

makeProof = async (
  proofId: supportedProofIds,
  inputs: CircuitSignals,
  node: string = `https://fc.omnid.io`
): Promise<FunctionCloudProofResponse>

relayProof

Example,

const res = await relayProof('11', []);

Reference,

relayProof = async (
  groupId: number,
  proofData: ProofData,
  relayEndpoint: string = "https://alchemy.omnid.io/relay/login",
): Promise<RelayResponse>

portalProof

Excute proofs on one chain and have them portalled to another.

Group Templates

These let you quickly get the addresses holding any token, NFT, Attestation, DAO etc.

fromToken

Example,

let data = await fromToken('0x00', 'eth', 'APIKEY');

Reference,

fromToken = async (
  token: string,
  chainName: string,
  COVALENT_APIKEY: string
): Promise<Array<TokenHolder>>

fromSnapshot

Example,

let data = await fromSnapshot(
  'aave.eth',
  '0xe03ecf69d92f04d39d1385ccc87d8782347471a7305897e85b3d5d04f26a522d',
);

Reference,

fromSnapshot = async (
  space: string,
  proposal: string | null = null,
  first: number = 1000,
  skip: number = 0
): Promise<SnapshotVote[]>

fromEas

Example,

let data = await fromEas(
  '0xe03ecf69d92f04d39d1385ccc87d8782347471a7305897e85b3d5d04f26a522d',
  '0x385ccc87d8782347471a7305897e85b3d5d04f26a522'
  1
);

Reference,

fromEas = async (
  schemaId: string,
  attestor: string,
  chainId: 1 | 10 | 8453 | 42161 | 59144 | 11155111 | 11155420 | 534351
): Promise<EasAttestation[]>

Query

getGroupIds

Example,

let ids = await getGroupIds();

Reference,

async getGroupIds(): Promise<string[]>

getGroups

Example,

let groups = await getGroups();

Reference,

async getGroups(options: {
  members?: boolean;
  validatedProofs?: boolean;
  filters?: {
    admin?: string;
    identityCommitment?: string;
    timestamp?: Date;
    timestampGte?: Date;
    timestampLte?: Date;
  };
}): Promise<{
  id: string;
  merkleTree: {
    root: string;
    depth: number;
    size: number;
  };
  admin?: string;
  members?: Array<{
    id: number;
    timestamp: number;
    identityCommitment: number;
    index: number;
  }>;
  validatedProofs?: {
    message: string;
    merkleTreeRoot: string;
    merkleTreeDepth: number;
    scope: string;
    nullifier: string;
    points: string[];
    timestamp?: string;
  }[];
}[]>

getGroup

Example,

let group = await getGroup(1);

Reference,

async getGroup(groupId: string, options: Omit<GroupOptions, "filters"> = {}): Promise<GroupResponse>

isGroupMember

Example,

let res = await isGroupMember(1, 'commitment');

Reference,

async isGroupMember(groupId: string, member: string): Promise<boolean>

SimpleMerkleTree

A utility class for you to quickly make merkle proofs.

makeTree

Reference,

makeTree(hashedValues: Array<bigint>) {}

getProof

Reference,

getProof(leafHash: bigint): {
    found: boolean;
    path: bigint[];
    pathInd: number[];
}: { found: true, path, pathInd }

getCalldata

Reference,

getCalldata(proof: {
    path: bigint[];
    pathInd: number[];
}, leafHash: bigint) {
    return JSON.stringify({
        leaf: this.bigint2hex(leafHash),
        path_elements: proof.path.map(this.bigint2hex),
        path_indices: proof.pathInd
    })
}

getRootHash

let root = getRootHash()

Vault

Internals about Vault

Stealth Addresses

Support for Ethereum stealth addresses as defined in EIP-5564 and EIP-6538

On this page