Documentation

Domain

A component for resolving and displaying Avalanche domain names for Ethereum addresses.

Domain

The Domain component resolves and displays Avalanche domain names for Ethereum addresses, with fallback to abbreviated addresses.

Usage

import { Domain } from '@avalabs/builderkit';
 
// Basic usage
<Domain address="0x1234567890123456789012345678901234567890" />
 
// With address fallback
<Domain 
  address="0x1234567890123456789012345678901234567890"
  showAddressIfNotAvailable={true}
/>
 
// Using context (inside Identity provider)
<Domain showAddressIfNotAvailable={true} />

Props

PropTypeDefaultDescription
addressstring-The Ethereum address to resolve domain for (optional if used within Identity context)
showAddressIfNotAvailablebooleanfalseShow abbreviated address if no domain is found

Features

  • Resolves Avalanche domain names using useAvaxDomain hook
  • Shows loading indicator while resolving
  • Optional fallback to abbreviated address display
  • Can use address from Identity context if not provided directly
  • Validates input addresses

Examples

Basic Domain Display

<Domain address="0x1234567890123456789012345678901234567890" />
// Output: "mydomain.avax" (if resolved)
// Output: null (if no domain found)

With Address Fallback

<Domain 
  address="0x1234567890123456789012345678901234567890"
  showAddressIfNotAvailable={true}
/>
// Output: "mydomain.avax" (if resolved)
// Output: "0x1234...5678" (if no domain found)

With Identity Context

<Identity address="0x1234567890123456789012345678901234567890">
  <Domain showAddressIfNotAvailable={true} />
</Identity>

States

  1. Loading: Shows a loading indicator while resolving the domain
  2. Resolved: Displays the resolved domain name
  3. Not Found:
    • Shows nothing if showAddressIfNotAvailable is false
    • Shows abbreviated address if showAddressIfNotAvailable is true

Error Handling

The component will throw an error if:

  • No address is provided (either via props or context)
  • The provided address is not a valid Ethereum address
Edit on GitHub

Last updated on

On this page