Skip to main content

Class: Subnames

Represents the Subnames class for interacting with the Subnames API.

Classdesc

Represents the Subnames class for interacting with the Subnames API.

Example

import { JustaName } from '@justaname.id/sdk';

const configuration = {
apiKey: 'your-api-key'
};

const justaName = JustaName.init(configuration);

const addedUser = await justaName.subnames.addSubname({
username: 'test',
ensDomain: 'test.eth',
chainId: 1,
},
{
xAddress: '0x59c44836630760F97b74b569B379ca94c37B93ca',
xMessage: '...',
xSignature: '...',
});

Constructors

constructor

new Subnames(apiKey?): Subnames

Constructs a new instance of the Subnames class, optionally with an API key for write operations.

Parameters

NameTypeDescription
apiKey?stringYour API key, required for operations that modify data.

Returns

Subnames

Defined in

lib/features/subnames/index.ts:67

Properties

apiKey

Private Readonly apiKey: undefined | string

Defined in

lib/features/subnames/index.ts:61

Methods

acceptSubname

acceptSubname(params, headers): Promise<SubnameAcceptResponse>

Accept a subname invite under a specific domain, associating it with an Ethereum address.

Parameters

NameTypeDescription
paramsSubnameAcceptRequestParameters for claiming a subname.
headersSIWEHeadersAdditional headers for signing and authentication.

Returns

Promise<SubnameAcceptResponse>

The result of the claim operation.

Defined in

lib/features/subnames/index.ts:77


addSubname

addSubname(params, headers): Promise<SubnameAddResponse>

Adds a new subname under a domain, directly associating it with an address and optional content. Requires an API key.

Parameters

NameTypeDescription
paramsSubnameAddRequestThe parameters for adding the subname.
headersSIWEHeadersAdditional headers for signing and authentication.

Returns

Promise<SubnameAddResponse>

The result of the add operation.

Defined in

lib/features/subnames/index.ts:110


checkSubnameAvailable

checkSubnameAvailable(params): Promise<IsSubnameAvailableResponse>

Checks if a subname is available for registration. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsIsSubnameAvailableRequestParameters for checking subname availability.

Returns

Promise<IsSubnameAvailableResponse>

Information about the subname's availability.

Defined in

lib/features/subnames/index.ts:267


getAllByAddress

getAllByAddress(params): Promise<SubnameGetAllByAddressResponse[]>

Retrieves all subnames associated with a specific address. This can be useful for users to see all subnames under their control. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsSubnameGetAllByAddressRequestThe parameters for the lookup.

Returns

Promise<SubnameGetAllByAddressResponse[]>

A list of subnames associated with the address.

Defined in

lib/features/subnames/index.ts:231


getAllCommunities

getAllCommunities(params): Promise<SubnameGetAllCommunitiesChainIdResponse>

Retrieves all communities with the count of subnames in each community.

Parameters

NameTypeDescription
paramsSubnameGetAllCommunitiesChainIdRequestThe parameters for the lookup.

Returns

Promise<SubnameGetAllCommunitiesChainIdResponse>

The details of the subname, if found.

Defined in

lib/features/subnames/index.ts:194


getByDomainNameChainId

getByDomainNameChainId(params): Promise<SubnameGetByDomainNameChainIdResponse>

Retrieves details of a subname by its domain name and chain ID. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsSubnameGetByDomainNameChainIdRequestThe parameters for the lookup.

Returns

Promise<SubnameGetByDomainNameChainIdResponse>

The details of the subname, if found.

Defined in

lib/features/subnames/index.ts:206


getBySubname

getBySubname(params): Promise<SubnameGetBySubnameResponse>

Retrieves details of a subname directly by its name. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsSubnameGetBySubnameRequestThe parameters for the lookup.

Returns

Promise<SubnameGetBySubnameResponse>

The details of the subname, if found.

Defined in

lib/features/subnames/index.ts:218


getCommunitySubnamesByDomain

getCommunitySubnamesByDomain(params): Promise<SubnameGetAllByDomainChainIdResponse>

Parameters

NameType
paramsSubnameGetAllByDomainChainIdRequest

Returns

Promise<SubnameGetAllByDomainChainIdResponse>

Defined in

lib/features/subnames/index.ts:237


getInvitations

getInvitations(params): Promise<SubnameGetAllByAddressResponse[]>

Retrieves all subname invitations for a specific address. This allows users to see any pending subname associations. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsSubnameGetAllByAddressRequestThe parameters for retrieving invitations.

Returns

Promise<SubnameGetAllByAddressResponse[]>

A list of subname invitations.

Defined in

lib/features/subnames/index.ts:255


getRecordsByFullName

getRecordsByFullName(params): Promise<SubnameRecordsResponse>

Retrieves the records associated with a subname. This is a read-only operation and does not require an API key.

Parameters

NameTypeDescription
paramsSubnameRecordsRequestParameters for retrieving subname records.

Returns

Promise<SubnameRecordsResponse>

The records associated with the subname.

Defined in

lib/features/subnames/index.ts:279


isNotReadOnlyMode

isNotReadOnlyMode<T>(callback): T

Ensures that the method is not called in read-only mode, throwing an error if an API key is not provided.

Type parameters

Name
T

Parameters

NameTypeDescription
callbackTThe operation to be performed.

Returns

T

The result of the callback operation if an API key is present.

Throws

If called in read-only mode without an API key.

Defined in

lib/features/subnames/index.ts:292


rejectSubname

rejectSubname(params, headers): Promise<SubnameRejectResponse>

Rejects a subname, removing its association and optionally freeing it for re-registration.

Parameters

NameTypeDescription
paramsSubnameRejectRequestThe parameters for rejecting the subname.
headersSIWEHeadersAdditional headers for signing and authentication.

Returns

Promise<SubnameRejectResponse>

The result of the revoke operation.

Defined in

lib/features/subnames/index.ts:179


reserveSubname

reserveSubname(params): Promise<SubnameReserveResponse>

Reserves a subname for later claiming. This can be useful for securing a subname before it is officially registered or claimed. Requires an API key.

Parameters

NameTypeDescription
paramsSubnameReserveRequestThe parameters for the reservation.

Returns

Promise<SubnameReserveResponse>

The result of the reservation operation.

Defined in

lib/features/subnames/index.ts:93


revokeSubname

revokeSubname(params, headers): Promise<SubnameRevokeResponse>

Revokes a subname, removing its association and optionally freeing it for re-registration. Requires an API key.

Parameters

NameTypeDescription
paramsSubnameRevokeRequestThe parameters for revoking the subname.
headersSIWEHeadersAdditional headers for signing and authentication.

Returns

Promise<SubnameRevokeResponse>

The result of the revoke operation.

Defined in

lib/features/subnames/index.ts:161


searchSubnames

searchSubnames(params): Promise<SubnameSearchResponse>

Parameters

NameType
paramsSubnameSearchRequest

Returns

Promise<SubnameSearchResponse>

Defined in

lib/features/subnames/index.ts:243


updateSubname

updateSubname(params, headers): Promise<SubnameUpdateResponse>

Updates the details of an existing subname. This operation can be used to change the associated address or the content of a subname. Requires an API key.

Parameters

NameTypeDescription
paramsSubnameUpdateRequestThe parameters for updating the subname.
headersSIWEHeadersAdditional headers for signing and authentication.

Returns

Promise<SubnameUpdateResponse>

The result of the update operation.

Defined in

lib/features/subnames/index.ts:144