Skip to content

getName

The getName utility is designed to retrieve a name from an onchain identity provider for a specific address.

Consider the utility instead of the hook when you use it with Next.js or any Node.js backend.

Usage

Get ENS name from an address:

code
import { getName } from '@coinbase/onchainkit/identity';
 
const address = '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1';
const name = await getName({ address });

Get Basename from an address:

code
import { getName } from '@coinbase/onchainkit/identity';
import { base } from 'viem/chains';
 
const address = '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1';
const name = await getName({ address, chain: base });

Get a sliced address when address does not have an ENS name:

code
import { getName } from '@coinbase/onchainkit/identity';
 
const address = '0x1234567890abcdef1234567890abcdef12345678';
const name = await getName({ address });

Returns

Promise<GetNameReturnType>

Parameters

GetName