IPNS

The Fleek Platform SDK helps you create mutable pointers to CIDs known as InterPlanetary Name System (IPNS) names. IPNS names can be thought of as links that can be updated over time, while retaining the verifiability of content addressing. In this case in particular, they are mostly used to represent IPFS files (through their hashes).

Create an IPNS record

// The Fleek SDK should be authenticated
// with a valid Project ID
const record = await fleekSdk.ipns().createRecord();

This returns an object with the following properties:

type IpnsRecord = {
  // The IPNS record ID on Fleek DB
  id: string;
  // The name of the IPNS record
  name: string;
  // The IPFS CID associated with the record
  hash: string;
};

Initially, all records are created with an empty IPFS hash. To add it, you will need to publish it.

You can query the record by name:

// The Fleek SDK should be authenticated
// with a valid Project ID
const record = await fleekSdk.ipns().getRecord({
  name: record.name,
});

How to publish an IPNS record

To publish an IPNS record, you need to provide the IPNS record name and the IPFS hash you want to associate with it.

// The Fleek SDK should be authenticated
// with a valid Project ID
const record = await fleekSdk.ipns().publishRecord({
  id: record.id,
  hash,
});

List all records

To list all the records associated with a project, use the listRecords method.

// The Fleek SDK should be authenticated
// with a valid Project ID
const records = await fleekSdk.ipns().listRecords();

Delete a record

To delete an IPNS record, use the deleteRecord method.

// The Fleek SDK should be authenticated
// with a valid Project ID
await sdk.ipns().deleteRecord({
  id: record.id,
});