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
Name | Type | Description |
---|---|---|
apiKey? | string | Your API key, required for operations that modify data. |
Returns
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
Name | Type | Description |
---|---|---|
params | SubnameAcceptRequest | Parameters for claiming a subname. |
headers | SIWEHeaders | Additional 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
Name | Type | Description |
---|---|---|
params | SubnameAddRequest | The parameters for adding the subname. |
headers | SIWEHeaders | Additional 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
Name | Type | Description |
---|---|---|
params | IsSubnameAvailableRequest | Parameters 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
Name | Type | Description |
---|---|---|
params | SubnameGetAllByAddressRequest | The 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
Name | Type | Description |
---|---|---|
params | SubnameGetAllCommunitiesChainIdRequest | The 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
Name | Type | Description |
---|---|---|
params | SubnameGetByDomainNameChainIdRequest | The 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
Name | Type | Description |
---|---|---|
params | SubnameGetBySubnameRequest | The 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
Name | Type |
---|---|
params | SubnameGetAllByDomainChainIdRequest |
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
Name | Type | Description |
---|---|---|
params | SubnameGetAllByAddressRequest | The 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
Name | Type | Description |
---|---|---|
params | SubnameRecordsRequest | Parameters 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
Name | Type | Description |
---|---|---|
callback | T | The 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
Name | Type | Description |
---|---|---|
params | SubnameRejectRequest | The parameters for rejecting the subname. |
headers | SIWEHeaders | Additional 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
Name | Type | Description |
---|---|---|
params | SubnameReserveRequest | The 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
Name | Type | Description |
---|---|---|
params | SubnameRevokeRequest | The parameters for revoking the subname. |
headers | SIWEHeaders | Additional 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
Name | Type |
---|---|
params | SubnameSearchRequest |
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
Name | Type | Description |
---|---|---|
params | SubnameUpdateRequest | The parameters for updating the subname. |
headers | SIWEHeaders | Additional headers for signing and authentication. |
Returns
Promise
<SubnameUpdateResponse
>
The result of the update operation.
Defined in
lib/features/subnames/index.ts:144