Integrate ANS into dApp
Query the primary name of an address
// 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
// 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();Convert ANS name_hash to Human-readable Name
// Replace "2161886410952211525886505790676792679800209349697935268316503861742165891860field" with your ANS name_hash.
const name_hash = "2161886410952211525886505790676792679800209349697935268316503861742165891860field";
const response = await fetch(`https://testnet-api.aleonames.id/hash_to_name/${name_hash}`);
const { name, balance } = await response.json();Query resolver content
Query avatar
Last updated