IPNS API
publishName, resolveName, resolveAndRetrieve, generateKey, listKeys — full reference.
publishName
publishName(
value: string,
options?: IpnsPublishOptions,
): Promise<IpnsPublishResult>Publish an IPNS record on the primary node. value is a CID string or /ipfs/... path.
const { name, value } = await meshkit.publishName('Qm...', {
key: 'latest',
ttl: '1m',
});
// name: "Qm..." (the IPNS key hash)
// value: "/ipfs/Qm..."IpnsPublishOptions
| Property | Type | Default | Description |
|---|---|---|---|
key | string | "self" | Keystore label. Use the name from generateKey. |
lifetime | IpnsDuration | ~48h | Record validity window. |
ttl | IpnsDuration | — | Cache hint for resolvers. |
resolve | boolean | true | Resolve value before publishing. |
IpnsPublishResult
| Property | Type | Description |
|---|---|---|
name | string | IPNS name hash — use as /ipns/${name}. |
value | string | Published path, e.g. /ipfs/Qm.... |
resolveName
resolveName(name: string, options?: IpnsResolveOptions): Promise<string>Resolve an IPNS name to an /ipfs/... path. Uses failover.
const path = await meshkit.resolveName('/ipns/Qm...');
console.log(path); // /ipfs/Qm...IpnsResolveOptions
| Property | Type | Default | Description |
|---|---|---|---|
recursive | boolean | — | Resolve until the result is not another IPNS name. |
nocache | boolean | — | Bypass local cache — useful after publish to verify propagation. |
resolveAndRetrieve
resolveAndRetrieve(name: string, options?: IpnsResolveOptions): Promise<Uint8Array>Resolve an IPNS name and retrieve the content bytes in one call. Uses failover.
const bytes = await meshkit.resolveAndRetrieve('/ipns/Qm...');generateKey
generateKey(name: string, options?: IpnsKeyGenOptions): Promise<IpnsKey>Create a named signing key in the primary node's keystore. The returned id is the stable IPNS name.
const key = await meshkit.generateKey('blog-latest');
// key.id — use as /ipns/<id>
// key.name — "blog-latest"IpnsKeyGenOptions
| Property | Type | Default | Description |
|---|---|---|---|
type | 'ed25519' | 'rsa' | — | Key algorithm. |
size | number | — | Key size (for RSA). |
listKeys
listKeys(): Promise<IpnsKey[]>List all keys in the primary node's keystore, including the built-in "self" key.
const keys = await meshkit.listKeys();
// [{ id: '...', name: 'self' }, { id: '...', name: 'blog-latest' }]IpnsKey
| Property | Type | Description |
|---|---|---|
id | string | Public key hash — the IPNS name. |
name | string | Keystore label, e.g. "self" or "blog-latest". |
TTL constants
import { IPNS_TTL_FAST, IPNS_TTL_DEFAULT } from '@ipfs-meshkit/meshkit';| Constant | Value | Use |
|---|---|---|
IPNS_TTL_FAST | "1m" | Frequent updates |
IPNS_TTL_DEFAULT | "1h" | Stable content |