useAddressSubnames
A React hook for fetching subnames owned by a specific Ethereum address.
Usage
import { useAddressSubnames } from '@justaname.id/react'
function AddressSubnamesComponent() {
const {
addressSubnames,
isAddressSubnamesPending,
isAddressSubnamesFetching,
isAddressSubnamesLoading,
refetchAddressSubnames
} = useAddressSubnames({
address: '0x1234567890abcdef1234567890abcdef12345678',
chainId: 1,
isClaimed: true,
coinType: 60
})
if (isAddressSubnamesLoading) return <div>Loading subnames...</div>
return (
<div>
<h3>Subnames for Address</h3>
{addressSubnames?.map((subname, index) => (
<div key={index}>
<strong>{subname.ens}</strong>
<p>{subname.sanitizedRecords?.description}</p>
<p>Claimed: {subname.isClaimed ? 'Yes' : 'No'}</p>
<p>JAN: {subname.isJAN ? 'Yes' : 'No'}</p>
</div>
))}
<button onClick={refetchAddressSubnames}>Refresh</button>
</div>
)
}
Returns
UseAddressSubnamesResult
- An object containing:
addressSubnames
: Array ofRecords
objects containing subname data withsanitizedRecords
propertyisAddressSubnamesPending
: Boolean indicating if the data is being fetchedisAddressSubnamesFetching
: Boolean indicating if the data is being fetchedisAddressSubnamesLoading
: Boolean indicating if the data is loadingrefetchAddressSubnames
: Function to manually refetch the data
Parameters
params:
UseAddressSubnamesParams
- Required parameters for the hook:address
:string
- Ethereum address to fetch subnames forchainId
:ChainId
- Chain ID for the queryisClaimed?
:boolean
- Filter by claimed status (default: true)coinType?
:number
- Coin type filterenabled?
:boolean
- Enable/disable the query
Defined in
packages/@justaname.id/react/src/lib/hooks/subname/useAddressSubnames.ts:43
Last updated
Was this helpful?