IPNS | SDK
In case you are using the Fleek SDK with a PAT as the authentication service you need to make sure that the projectId is set in the PersonalAccessTokenService.
How to Create an IPNS Record
To create an IPNS record using the SDK, you need to be authenticated and have a project selected.
const record = await sdk.ipns().createRecord();
This returns an object with the following properties:
id: The IPNS record ID on Fleek DB.
name: The name of the IPNS record.
hash: The IPFS CID associated with the record.
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:
const record = await sdk.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.
const record = await sdk.ipns().publishRecord({ id: record.id, hash });
It is important to note that IPNS propagation can take anywhere from 1 to 30 minutes.
List All Records
To list all the records associated with a project, use the listRecords
method.
const records = await sdk.ipns().listRecords();
Delete a Record
To delete an IPNS record, use the deleteRecord
method.
await sdk.ipns().deleteRecord({ id: record.id });
Remember that IPNS propagation can take from 1 to 30 minutes.