ENS Logo


Personalization of profiles is what makes identity great. This page covers the very special avatar record that enables users to take their avatar with them across the web.


Getting the user's Avatar

Avatars are an awesome way for users to express themselves. To get the user's avatar, all you need is their name. If you only have their address, see primary names. The following code snippets let you get the avatar for a user.

import { namehash } from "viem"

const nameWrapper = '0x44640D662A423d738D5ebF8B51E57AfC0f2cf4Df'
const network = 'mainnet'
const getUrl = (hash: string) => {
  return `https://rns-metadata.fly.dev/${network}/${nameWrapper}/${hash}`

const url = getUrl(namehash('rns.root'))

const main = async () => {
  // Fetch metadata for name
  const res = await fetch(url)
  console.log(await res.json())

  // Fetch iamge for name
  const resImage = await fetch(url + '/image')
  console.log(await resImage.text())

The Metadata Service

The metadata service is run by RNS. It is a free service web service that allows you to retrieve the avatar of an RNS name via a web request, as opposed to adding extra logic to your application and interacting with an ethereum node. This is of course centralised and should be used if absolutely necessary.