Integrate ANS into Frontend

The API service provided by aleo-name-service-api. We recommend that developers run their own Indexer, but developers can use the official ANS Indexer service for development and testing during the development phase.

Query the primary name of an address

Check if an address has set a primary domain name. A 404 response means it has not been configured.

// Replace "aleo1s......abcdef" with the address you want to lookup.
const address = "aleo1s......abcdef";
const response = await fetch(`https://testnet-api.aleonames.id/primary_name/${address}`);
const { name } = await response.json();

Convert ANS name to address

Check if a domain name has a corresponding address. A 404 response indicates that it has not been registered. If the returned address is not an Aleo address, it means the domain is privately registered and not publicly disclosed.

// Replace "test.ans" with your ANS name. 
// For private name, the address will be "Private Registration".
const name = "test.ans";
const response = await fetch(`https://testnet-api.aleonames.id/address/${name}`);
const { address } = await response.json();

Query resolver content

Query a domain name's configured resolver content. A 404 response indicates it has not been set up. If configured

// Replace "test.ans" with your ANS name. replace category with category you want to lookup.
const name = "test.ans";
const category = "btc";
const response = await fetch(`https://testnet-api.aleonames.id/resolver?name=${name}&category=${category}`);
const { content } = await response.json();

Query avatar

The avatar falls under a resolver category. To retrieve a domain name's assigned avatar, specify category="avatar". If an avatar has been set up, the 'content' will point to the avatar image hosted on IPFS.

Last updated