Skip to content

DW Client SDK Reference

fetchCampaignBySlug

Fetch a campaign by its slug.

Usage

javascript
const campaign = await dwClient.fetchCampaignBySlug(slug);
const campaign = await dwClient.fetchCampaignBySlug(slug);

Parameters

  • slug - string (required) - The slug of the campaign to retrieve

Returns

Returns a Campaign object.

json
{
  "id": 1,
  "domainId": 1,
  "name": "test",
  "slug": "test",
  "description": "...",
  "quantity": 100,
  "price": 0,
  "currency": "USD",
  "duration": 2,
  "enableDefaultBlacklist": true,
  "customBlacklist": "badword1, badword2",
  "status": "ACTIVE",
  "createdAt": "datetime",
  "updatedAt": "datetime",
  "domain": {
    "TLD": "example.com",
  }
}
{
  "id": 1,
  "domainId": 1,
  "name": "test",
  "slug": "test",
  "description": "...",
  "quantity": 100,
  "price": 0,
  "currency": "USD",
  "duration": 2,
  "enableDefaultBlacklist": true,
  "customBlacklist": "badword1, badword2",
  "status": "ACTIVE",
  "createdAt": "datetime",
  "updatedAt": "datetime",
  "domain": {
    "TLD": "example.com",
  }
}
  • id - string: The campaign ID.
  • domainId - string: Associated domain ID.
  • name - string: Campaign name.
  • slug - string: Campaign slug.
  • description - string: Campaign description.
  • quantity - number: Number of domain wallets to sell.
  • price - number: Cost of each domain wallet. Fixed at 0.
  • currency - string: Currency of the price. Fixed to USD.
  • duration - number: Duration of domain wallet ownership.
  • enableDefaultBlacklist - boolean: Whether to enable the default blacklist. Defaults to true.
  • customBlacklist - string: List of domain names to blacklist separated by commas.
  • status - string: Whether the campaign is active.
  • createdAt - string: When the campaign was created.
  • updatedAt - string: When the campaign was last updated.
  • domain:
    • TLD - string: The top-level domain.

checkDomainAvailability

Checks if a domain is available for registration.

Usage

javascript
const isAvailable = await dwClient.checkDomainAvailability({
  FQDN: 'happy.example.com',
});
const isAvailable = await dwClient.checkDomainAvailability({
  FQDN: 'happy.example.com',
});

Parameters

  • body - CheckDomainAvailableBody (required)
    • FQDN - string: The domain name to check availability for.

Returns

Returns a boolean indicating whether the domain is available. True if domain is available, false if it is not.

reserveDomain

Reserve the desired domain for a limited period of time.

Usage

javascript
const { sessionId, startedAt } = await dwClient.reserveDomain({
  FQDN: 'happy.example.com'
});
const { sessionId, startedAt } = await dwClient.reserveDomain({
  FQDN: 'happy.example.com'
});

Parameters

  • body - ReserveDomainBody (required)
    • FQDN - string (required): The domain to reserve.

Returns

Returns data confirming that the domain has been reserved.

json
{ 
  "sessionId": "session-2",
  "startedAt": "datetime",
}
{ 
  "sessionId": "session-2",
  "startedAt": "datetime",
}
  • sessionId - string: The session ID to track the progress of domain registration.
  • startedAt - string: The time at which the domain reservation started.

registerDomain

Register the domain and create a domain wallet with the given auth method.

Usage

javascript
const hasRegistrationStarted = await dwClient.registerDomain({
  sessionId: 'session-1',
  userId: 'hello@alice.com',
  authMethod: {
    authMethodType: 1,
    authMethodId: "hash",
    authMethodPubkey: "0x"
  },
});
const hasRegistrationStarted = await dwClient.registerDomain({
  sessionId: 'session-1',
  userId: 'hello@alice.com',
  authMethod: {
    authMethodType: 1,
    authMethodId: "hash",
    authMethodPubkey: "0x"
  },
});

Parameters

  • sessionId string (required): The session ID to track the progress of domain registration
  • userId - string (required): User's email, phone, Ethereum address, or app-specific id.
  • authMethod - PKPRegistrationInfo (required): The authentication method that will be associated with the domain wallet.
    • authMethodType - number: The type of authentication method.
    • authMethodId - string: ID of the authentication method.
    • authMethodPubkey - string: WebAuthn public key if WebAuthn is used. Otherwise, include 0x.

Returns

Returns a boolean indicating if registration has been successfully kicked off. True if registration has started, false if it has not.

getRegistrationStatus

Get the domain registration state for the given domain.

Usage

javascript
const { status, message, data } = await dwClient.getRegistrationStatus({
  FQDN: 'happy.example.com',
});
const { status, message, data } = await dwClient.getRegistrationStatus({
  FQDN: 'happy.example.com',
});

Parameters

  • body - FQDNOnlyBody (required)
    • FQDN - string (required): The domain to lookup registration state for.

Returns

Returns the registration state associated with the given domain if found.

json
{
  "data": {
    "status": "DOMAIN_RESERVED",
    "FQDN": "happy.example.com",
    "PKPInfo": {
      "publicKey": "...",
      "ethAddress": "...",
      "tokenIdHex": "...",
      "tokenIdDecimal": {
        "hex": "...",
        "type": "BigNumber"
      }
    },
    "error": null
  }
}
{
  "data": {
    "status": "DOMAIN_RESERVED",
    "FQDN": "happy.example.com",
    "PKPInfo": {
      "publicKey": "...",
      "ethAddress": "...",
      "tokenIdHex": "...",
      "tokenIdDecimal": {
        "hex": "...",
        "type": "BigNumber"
      }
    },
    "error": null
  }
}
  • data - object:

    • status - string: The domain registration status. Value can be DOMAIN_RESERVED, NEW_USER, USER_REGISTERED, SAVED_ON_CHAIN, DNS_UPDATED, or COMPLETED.
    • FQDN - string: The full qualified domain name.
    • PKPInfo - object - Domain wallet info including its public key, eth address, and token ID.
    • error - string: The error type if the domain registration failed. Value can be null, RESERVING_DOMAIN_ERROR, REGISTERING_USER_ERROR, SAVING_ON_CHAIN_ERROR, UPDATING_DNS_ERROR, or COMMITTING_TO_DB_ERROR.
    Domain registration error typeMeaning
    RESERVING_DOMAIN_ERRORFailed to reserve domain. Reasons may include: domain is already reserved, domain has been registered, or invalid domain.
    REGISTERING_USER_ERRORFailed to save the auth method that will be linked to the domain wallet.
    SAVING_ON_CHAIN_ERRORFailed to save domain wallet on-chain.
    UPDATING_DNS_ERRORFailed to update the DNS record.
    COMMITTING_TO_DB_ERRORFailed to save changes to the domain registration state.

pollStatus

Polls the domain registration status of a given domain. It periodically fetches the status at a given interval, until a COMPLETED status is reached, or until a state is stuck for more than a predefined timeout period. Invokes a provided callback function each time a new status is detected.

Usage

javascript
dwClient.pollStatus('happy.example.com', status =>
  console.log(`Status detected: ${status}`)
);
dwClient.pollStatus('happy.example.com', status =>
  console.log(`Status detected: ${status}`)
);

Parameters

  • FQDN - string (required): The full qualified domain name.
  • callback - (status: string, error?: any) => void (required): A callback function to be invoked each time a new status is detected.
  • opts - object (optional):
    • timeout - number: The timeout period in milliseconds. Default is 60000 ms.
    • interval - number: The interval at which to poll the status in millisconds. Default is 1000 ms.
    • endState - string: The domain registration state at which to stop polling. Default is COMPLETED.
    • maxRetryCount - number: The maximum number of retries before giving up. Default is 7.

Returns

json
{
  "lastState": "DNS_UPDATED",
  "status": "COMPLETED"
}
{
  "lastState": "DNS_UPDATED",
  "status": "COMPLETED"
}
  • lastState - string: The final domain registration status polled. Value can be DOMAIN_RESERVED, NEW_USER, USER_REGISTERED, SAVED_ON_CHAIN, DNS_UPDATED, or COMPLETED.
  • status - string: The given endState (defaults to COMPLETED), or ERROR if an error has occurred.

getSaleEventByRegisteredDomain

Get sale information associated with a domain wallet by its domain.

Usage

javascript
const saleEvent = await dwClient.getSaleEventByRegisteredDomain(
  'happy.example.com'
);
const saleEvent = await dwClient.getSaleEventByRegisteredDomain(
  'happy.example.com'
);

Parameters

  • domain - string (required): The domain of the registered domain wallet.

Returns

Returns sale information associated with the given domain if found.

json
{
  "data": {
    "domainId": 1,
    "campaignId": 1,
    "pkpTokenId": "0x...",
    "registrationEndDate": "datetime",
    "transactionHash": "0x...",
    "createdAt": "datetime"
  }
}
{
  "data": {
    "domainId": 1,
    "campaignId": 1,
    "pkpTokenId": "0x...",
    "registrationEndDate": "datetime",
    "transactionHash": "0x...",
    "createdAt": "datetime"
  }
}
  • data - object:
    • domainId - string: ID of top level domain associated with the domain wallet.
    • campaignId - string: ID of campaign associated with the domain wallet.
    • pkpTokenId - string: Token ID of PKP associated with the domain wallet.
    • registrationEndDate - string: When the domain associated with the domain wallet expires.
    • transactionHash - string: Unique identifier for the on-chain transaction associated with the minting of the domain wallet.
    • createdAt - string: When the sale occurred.