API Calls
This page shows how to use the SDK API module for common read operations. The examples on this page cover operator lookup, owner nonce retrieval, and cluster snapshot retrieval.
For the full list of available functions, see the API Module Reference.
Prerequisites
Before using these examples, make sure you have the SDK initialized.
Get Operators by IDs
Use sdk.api.getOperators to retrieve operator metadata (including decoded public keys) for a set of operator IDs.
const operators = await sdk.api.getOperators({ operatorIds: ["1", "2", "3", "4"]})
console.log(operators)Get Owner Nonce
Use sdk.api.getOwnerNonce to retrieve the current nonce for an account.
const ownerNonce = await sdk.api.getOwnerNonce({ owner: "0xA4831B989972605A62141a667578d742927Cbef9" }) console.log(ownerNonce)Get Cluster Snapshot
Use sdk.api.toSolidityCluster to retrieve the cluster snapshot in a format compatible with on-chain interactions.
import { createClusterId } from '@ssv-labs/ssv-sdk/utils'
const ownerAddress = "0xA4831B989972605A62141a667578d742927Cbef9"const operatorIds = ["1", "2", "3", "4"]const clusterId = createClusterId(ownerAddress, operatorIds)
const clusterSnapshot = await sdk.api.toSolidityCluster({ id: clusterId})console.log(clusterSnapshot)