The namespace-sdk
provides an easy-to-use client for managing ENS subnames off-chain. With this SDK, developers can create, update, delete, and query subnames, as well as manage associated records like addresses, text records, and data records.
If you've already done this, feel free to skip this step.
To issue subnames, make them resolvable, and get an API key, you need to go to our Dev Portal.
- Subnames section allows you to create, edit, or update subnames and all of their records (text, addresses, content hash)
- Resolution section is there for you to update the Resolver contract to Namespace Hybrid resolver so the subnames issued are resolvable in all ENS-supported apps.
- API Keys section allows you to create and manage API keys for ENS names you're issuing subnames from.
npm install @namespacesdk/offchain-manager
or using Yarn:
npm install @namespacesdk/offchain-manager
import { OffchainClient } from '@namespacesdk/offchain-manager';
To use the SDK, create an instance of the OffchainClient
and set your API key, which you can obtain from https://dev.namespace.ninja.
const client = new OffchainClient();
client.setApiKey('your-ens-name.eth', 'your-api-key');
import { ChainName } from "@namespacesdk/offchain-manageR"
await client.createSubname({
parent: 'example.eth',
label: 'sub',
addresses: [
{
chain: ChainName.Ethereum
value: "0x123..."
}
],
texts: [
{
key: "avatar",
value: "https://my_avatar_url"
}
]
});
await client.updateSubname('sub.example.eth', {
addresses: [
{
chain: ChainName.Ethereum
value: "0x123..."
}
],
texts: [
{
key: "avatar",
value: "https://my_avatar_url"
}
]
});
await client.deleteSubname('sub.example.eth');
const response = await client.isSubnameAvailable('sub.example.eth');
console.log(response.available);
const subname = await client.getSingleSubname('sub.example.eth');
console.log(subname);
const subnames = await client.getFilteredSubnames({ parent: 'example.eth' });
console.log(subnames);
import { ChainName } from "@namespacesdk/offchain-manager"
await client.addAddressRecord('sub.example.eth', ChainName.Ethereum, '0xYourEthereumAddress');
await client.deleteAddressRecord('sub.example.eth', ChainName.Base);
await client.addTextRecord('sub.example.eth', 'twitter', '@yourhandle');
await client.deleteTextRecord('sub.example.eth', 'twitter');
const records = await client.getTextRecords('sub.example.eth');
console.log(records);
const record = await client.getTextRecord('sub.example.eth', 'twitter');
console.log(record);
await client.addDataRecord('sub.example.eth', 'customData', { key: 'value' });
await client.deleteDataRecord('sub.example.eth', 'customData');
const dataRecords = await client.getDataRecords('sub.example.eth');
console.log(dataRecords);
const dataRecord = await client.getDataRecord('sub.example.eth', 'customData');
console.log(dataRecord);
Sets the API key for authentication.
Creates a new subname under a parent domain.
Updates an existing subname.
Deletes a subname.
Checks if a subname is available.
Retrieves details of a subname.
Fetches subnames based on query parameters.
Adds an address record to a subname.
Deletes an address record.
Adds a text record to a subname.
Deletes a text record.
Retrieves all text records for a subname.
Retrieves a specific text record.
Adds a data record to a subname.
Deletes a data record.
Retrieves all data records for a subname.
Retrieves a specific data record.
This project is licensed under the MIT License.
For any issues or feature requests, please open an issue on GitHub.
Contributions are welcome! Please read our contributing guidelines before submitting a pull request.
Consider joining the Namespace Builders group chat on Telegram if you have any questions, suggestions, feedback, or anything you want to talk about.