Skip to content

getAvatar

The getAvatar utility is designed to retrieve an avatar image URL from an onchain identity provider for a given name.

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

Supported providers:

Usage

Get Basename avatar:

code
import { getAvatar } from '@coinbase/onchainkit/identity';
import { base, mainnet } from 'viem/chains';
 
const baseAvatar = await getAvatar({ ensName: 'paulcramer.eth', chain: base });

Get ENS avatar:

code
import { getAvatar } from '@coinbase/onchainkit/identity';
import { mainnet } from 'viem/chains';
 
const ensAvatar = await getAvatar({ ensName: 'paulcramer.eth', chain: mainnet });

Returns

Promise<GetAvatarReturnType>