Skip to content

getNames

The getNames utility is designed to retrieve multiple names from an onchain identity provider for an array of addresses in a single batch request.

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

Usage

Get ENS names from multiple addresses:

code
import { getNames } from '@coinbase/onchainkit/identity';
 
const addresses = [
  '0x4bEf0221d6F7Dd0C969fe46a4e9b339a84F52FDF',
  '0x838aD0EAE54F99F1926dA7C3b6bFbF617389B4D9'
];
const names = await getNames({ addresses });

Get Basenames from multiple addresses:

code
import { getNames } from '@coinbase/onchainkit/identity';
import { base } from 'viem/chains';
 
const addresses = [
  '0x4bEf0221d6F7Dd0C969fe46a4e9b339a84F52FDF',
  '0x4bEf0221d6F7Dd0C969fe46a4e9b339a84F52FDF'
];
const names = await getNames({ addresses, chain: base });

Get a mix of ENS names and sliced addresses when some addresses don't have names:

code
import { getNames } from '@coinbase/onchainkit/identity';
 
const addresses = [
  '0x4bEf0221d6F7Dd0C969fe46a4e9b339a84F52FDF',
  '0x1234567890abcdef1234567890abcdef12345678'
];
const names = await getNames({ addresses });

Returns

Array of GetNameReturnType

Parameters

GetNames

GetNames