Install
@stellar/stellar-sdk (>=13 <17). The package is ESM, ships TypeScript types, and runs in both browsers (WebCrypto) and Node (node:crypto) with no bundler shims.
Published on npm as
@sorandomains/lookup; source on GitHub.The simplest setup
Network presets
Thetestnet preset (the default) ships these values, exported as DEPLOYMENTS:
A
mainnet preset is populated at mainnet launch. Until then, targeting mainnet means passing rpcUrl, passphrase, registryId, and primaryId: null explicitly — the constructor always starts from a preset and explicit fields override it, so omitting primaryId would inherit the testnet PrimaryName id from the default preset.
Bring your own RPC
Every SDK call is a read-only Soroban RPC simulation, so the RPC endpoint is the one piece of infrastructure you actually trust. Point it anywhere — including your own node:All options
primaryId— the platform-deployed PrimaryName contract (one immutable instance per network).undefinedinherits the preset;nullexplicitly disables the primary-name feature even when the preset ships one. See reverse lookup and primary names.registrars— for namespaces that run closed (registrar-side) resolution instead of a public resolver, map the namespace label to its Registrar contract id andresolve()will ask it directly.reverseNamespaces— reverse records live on per-namespace resolvers, and the chain cannot enumerate namespaces, soreverseLookupmust be told which ones to probe. Defaults to[].resolverCacheTtlMs— how long the namespace→resolver pointer is cached. The pointer can change for a reclaimable namespace, so long-lived instances should keep this bounded (default 30 seconds;0disables caching).hintUrl— a liveness-only fallback that supplies the list of namespaces to probe whenreverseNamespacesisn’t set. It is never in the trust path: a lying hint can hide a name, never forge one.
Fail-closed construction
Configuration mistakes surface atnew Soran(...), not deep inside your render path:
- A malformed
primaryId(not aC…contract strkey) throws aSoranErrorimmediately. - A malformed label in
reverseNamespacesthrows aSoranErrorimmediately.
Next
Resolving names
resolve, verify, records — and the confirm-time re-check.
SDK reference
Every method and type in one table.