Resolving NNS Names
There are 2 ways to resolve addresses to NNS Names: calling the NNSResolver or our API.
Resolving via the API
You just need to make a POST request to https://api.nns.nyz/resolve with
{
"address": "0x123...456",
// clds is optional and defaults to []
"clds": [
"0x1",
"0x2",
],
// fallback is optional and defaults to true
"fallback": true,
// disable_v1 is optional and when true disables the resolution of v1 names
"disable_v1": false
}which will return
{
"name": "hello.⌐◨-◨" // or null
}Resolving by calling the contract
You just need to call
on the resolver. The inputs are the same as the API call.
Inputs
addressis the address that will be resolvedcldsis an array of cld ids to perform a lookup onfallbackwhether you want to fallback to the default cld in case no lookup is found in the given list
Common Scenario
The most common scenario is to let the owner choose where they want to be resolved and this can be done by simply omitting the clds and setting the fallback to true.
As people migrate their old NNS name to the new contracts, we recommend to also integrate with the old NNS resolver as shown here. This is give one, with one simple integration:
Resolution of NNS v2 names
Resolution of NNS v1 names
Fallback to .eth names
in this order of priority.
Code Samples
The code below assumes you are using wagmi and @tanstack/react-query.
API call
As an example, if you only want to resolve .nouns names you can pass:
Note however that this is going to return null if the account has no .nouns. We recommend to set fallback: true to ensure you get one resolution back.
Contract call
In this example, you can simply return v2Name if you don't want to use the old resolver.
Last updated