Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving ENS name associated with an ENS NFT #184

Open
coopermaruyama opened this issue Jun 12, 2024 · 2 comments
Open

Resolving ENS name associated with an ENS NFT #184

coopermaruyama opened this issue Jun 12, 2024 · 2 comments

Comments

@coopermaruyama
Copy link

I have looked through the docs and codebase and have not been able to find a way to find out the ENS name associated with an ENS NFT, given I know the token ID and contract address of the NFT. Is this supported via the SDK and I'm just missing something?

For example, I'm looking for a way to successfully implement the following hypothetical function using the SDK:

const name = await getENSName({
  contractAddress: '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85',
  tokenId: '79233663829379634837589865448569342784712482819484549289560981379859480642508'
})

console.log(name) // "vitalik.eth"

Is this possible with the SDK? If not, is it possible to do this at all? I was expecting to just be able to query tokenURI() like with any other ERC-721 contract but it looks like the implementation used by ENS does not implement this. Any info would be appreciated, thanks.

@talentlessguy
Copy link
Collaborator

You could resolve a name by calling an ownerOf(tokenId) and then doing reverse resolution

@coopermaruyama
Copy link
Author

that will only give me the name that the owner set as their primary. if someone has more than one then i'll get the wrong one on the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants