Query contract directly
You can query contract directly for resolved address, primary name, attributes,...
getResolvedAddress
Resolved address for a name
getResolvedAddresses
Resolved addresses for a list of name
getPrimaryNameForAddress
Primary name for an address (Without TLD .nad)
getPrimaryNameForAddresses
Primary names for a list of address (Without TLD .nad)
getNameAttribute
An attribute associated with a name
getNameAttributes
Attributes associated with a name
getProfileForAddress
Return a profile for a wallet address, including primary name, avatar, ...
getProfilesForAddresses
Return profiles for a list of wallet address, including primary name, avatar, ...
For more information about contract address and ABI, checkout Contracts
Example:
Viem:
// Replace with your contract address
const nnsContractAddress = '0x...'
// Create contract instance
const contract = getContract({
address: nnsContractAddress,
abi: contractAbi,
publicClient,
walletClient
})
try {
// Example domain
const normalizedName = normalize('salmo.nad');
const node = namehash(normalizedName);
// 1. Get resolved address for a name
const resolvedAddress = await contract.read.getResolvedAddress([node])
console.log(`Resolved address for ${domain}:`, resolvedAddress)
// 2. Get primary name for an address
const address = '0x1234567890123456789012345678901234567890'
const primaryName = await contract.read.getPrimaryNameForAddress([address])
console.log('Primary name for address:', primaryName)
// 3. Get single name attribute
const attributeKey = 'avatar'
const attributeValue = await contract.read.getNameAttribute([node, attributeKey])
console.log(`Attribute ${attributeKey}:`, attributeValue)
// 4. Get multiple name attributes
const attributeKeys = ['avatar', 'email', 'url']
const attributes = await contract.read.getNameAttributes([node, attributeKeys])
console.log('Multiple attributes:', attributes)
} catch (error) {
console.error('Error:', error)
}Ethersjs:
Pros & Cons
✅ Pro
You are in full control
Minimal dependencies: only requires blockchain client, ABI, and custom name processing.
Immediate access to all on-chain data if you manage smart-contract permissions and upgrades.
Decentralized: No reliance on external APIs or services
⚠️ Cons
Manual name processing: you must normalize and compute namehash yourself for each query.
Boilerplate code: constructing contract instances and handling RPC logic manually.
Verbosity & error-prone: more setup work, especially for batch queries.
Maintenance Burden: Need to track contract updates and ABI changes
Last updated