Resolve ENS and Lens Profiles

Here we learn how to resolve a user's ENS or Lens profile data.

SSX can resolve ENS Names or Lens profiles when signing in with a simple flag. After signing in, the ENS data will be available with all other session data.

Resolving ENS Names

resolveEns can be a boolean (default: false) or an object.

Check out the complete resolveEns feature description here.

It's possible to resolve the ENS domain and avatar on the client during the sign-in, as in the example below:

/* resolve ENS domain and avatar on client */
const ssx = new SSX({
  resolveEns: true
});
const { ens } = await ssx.signIn();

You can also configure what you want to resolve and if you want to resolve it on the client or server during the sign-in, as in the example below:

/* resolve ENS domain and/or avatar on client or server */
const ssx = new SSX({
  resolveEns: {
    resolveOnServer: false, // false as default
    resolve: {
      domain: true,
      avatar: false
    }
  }
});
const { ens } = await ssx.signIn();

But if you don't want to resolve the ENS Names during the sign-in or if you want to resolve it for a different address, you can do as in the example below:

/* You can resolve ENS at any time, even if you
 * don't want to enable ENS resolution globally */
const ssx = new SSX();
await ssx.signIn();
const ensData = await ssx.resolveEns("0xADDRESS", {
    domain: false,
    avatar: true,
});

Resolving Lens

To retrieve Lens profiles, a similar flag and options are available.

This feature is available for Polygon Mainnet and Mumbai Testnet. Visit the Lens docs for more information.

resolveLens can be a boolean (default: false) or a string.

Check out the complete resolveEns feature description here.

It's possible to resolve the Lens profiles on the client during the sign-in, as in the example below:

/* resolve Lens profiles on client */
const ssx = new SSX({
  resolveLens: true
});
const { lens } = await ssx.signIn();

You can also configure to resolve the Lens profiles on an SSX-powered server, as in the example below:

/* resolve Lens profiles on server */
const ssx = new SSX({
  resolveLens: 'onServer'
});
const { lens } = await ssx.signIn();

But if you don't want to resolve the Lens profiles during the sign-in or if you want to resolve it for a different address, you can do as in the example below:

/* You can resolve Lens profiles at any time even if you
 * don't want to enable Lens resolution globally */
const ssx = new SSX();
await ssx.signIn();
const lensProfiles = await ssx.resolveLens("0xADDRESS");

Getting Data from the Session

If you've enabled name resolution, you can access it in the following ways:

This resolveLens feature is available for Polygon Mainnet and Mumbai Testnet. Visit the Lens docs for more information.

/* resolve ENS and Lens profiles on client */
const ssx = new SSX({
  resolveEns: true,
  resolveLens: true
});

/* sign in with Ethereum*/
await ssx.signIn();

/* ENS Data*/
const { domain, avatarUrl } = ssx.session()?.ens ?? {};

/* Lens Data*/
const { lens } = ssx.session() ?? {};
if (typeof lens === 'object') {
  const nextLensProfilesPage = await ssx.resolveLens(
    ssx.address() ?? '', 
    lens?.pageInfo?.next
  );
}

Last updated