Skip to content

useEnsLookup

Hook for looking up ENS name for address.

import { useEnsLookup } from 'wagmi'

Usage

import { useEnsLookup } from 'wagmi'
const App = () => {
const [{ data, error, loading }, lookupAddress] = useEnsLookup({
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
if (loading) return <div>Fetching name…</div>
if (error || !data) return <div>Error fetching name</div>
return <div>{data}</div>
}

Return Values

state

{
data?: string
error?: Error
loading?: boolean
}

lookupAddress

(config: { address: string }) => Promise<string | Error>

Configuration

address (optional)

Address to look up.

import { useEnsLookup } from 'wagmi'
const App = () => {
const [{ data, error, loading }, lookupAddress] = useEnsLookup({
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
return ...
}

skip (optional)

Skips automatically fetching data on mount. Defaults to false. Useful if you want to call lookupAddress manually at some other point.

import { useEnsLookup } from 'wagmi'
const App = () => {
const [{ data, error, loading }, lookupAddress] = useEnsLookup({
skip: true,
})
return ...
}