Allows the lookup of on-chain NFDomain metadata by address. Can be used by either the client or server to fetch the metadata for a given address.
- Using npm:
$ npm install @nettlelabs/nfd-lookup
- Using yarn:
$ yarn add @nettlelabs/nfd-lookup
import { INfdMetadata, lookupNfDomainByAddress } from '@nettlelabs/nfd-lookup';
import { Algodv2 } from 'algosdk';
const algodClient: Algodv2 = new Algodv2(
'',
'https://testnet-api.algonode.cloud',
''
); // first initialize your algod client
const metadata: INfdMetadata | null = await lookupNfDomainByAddress(
'QSTBDZMDPUHM6LESD54ZUT55KICOECJ4CPOMLAWNMSS3563ZK64HKJ65TM',
{
algodClient,
registryAppId: BigInt('84366825'), // this application ID MUST be the right one for the network
},
);
if (metadata) {
console.info(metadata.name); // kieran.algo
}
Lookup NFDomain metadata for an Algorand address (public key) on-chain.
Name | Type | Description |
---|---|---|
address | string |
The Algorand address (public key) to lookup. |
An additional object must be provided:
Name | Type | Default | Description |
---|---|---|---|
algodClient | Algodv2 |
- | An initialized Algod client that will be used to query the chain. |
debug | ILogLevel |
silent |
Whether logs will be printed to console. Can be one of debug , error , info , silent or warn . Defaults to silent . |
registryAppId | bigint |
- | the registry app ID for the NFDomain you want to lookup. NOTE: you must use the correct registry that matches the client network connection. See Registry Application IDs. |
Type | Description |
---|---|
Promise<INfdMetadata> or Promise<null> |
An object containing the metadata for this address or null if no NFDomain exists for address or an error was encountered. See the available properties. |
import { INfdMetadata, lookupNfDomainByAddress } from '@nettlelabs/nfd-lookup';
import { Algodv2 } from 'algosdk';
const algodClient: Algodv2 = new Algodv2(
'',
'https://testnet-api.algonode.cloud',
''
); // first initialize your algod client
const metadata: INfdMetadata | null = await lookupNfDomainByAddress(
'QSTBDZMDPUHM6LESD54ZUT55KICOECJ4CPOMLAWNMSS3563ZK64HKJ65TM',
{
algodClient,
registryAppId: BigInt('84366825'), // this application ID MUST be the right one for the network
},
);
console.info(result);
/*
Prints:
{
internal: {
asaid: '91947211',
category: 'premium',
commission1: '\x00\x00\x00\x00\x00\x00\x002',
commission1Agent: '7ZZWL6MDVXBOWQPEFEAQQ3LKV755ONNMCBKO2WB3GARF5F2IQVJ5KYGTZY',
contractLocked: '0',
highestSoldAmt: '269000000',
name: 'kieran.algo',
owner: 'QSTBDZMDPUHM6LESD54ZUT55KICOECJ4CPOMLAWNMSS3563ZK64HKJ65TM',
saleType: 'buyItNow',
seller: 'QSTBDZMDPUHM6LESD54ZUT55KICOECJ4CPOMLAWNMSS3563ZK64HKJ65TM',
timeChanged: '1667805899',
timeCreated: '1653460340',
timePurchased: '1653460421',
ver: '1.13g'
},
verified: {},
userDefined: {}
}
*/
- Install Yarn v1.22.5+
- Install the dependencies:
$ yarn install
- To build simply run:
$ yarn build
This will compile the Typescript source code into a dist/
directory.
- Registry Application IDs - the Algorand Application IDs for the NFD registry contract.
- nfd-cli-examples - an almost identical Go implementation (it was the template for this repo).
Please read the Contributing Guide to learn about the development process.
Please refer to the LICENSE file.
- A massive shout-out to TxnLab and the amazing work they are doing for the Algorand ecosystem. ❤️