1.1.0 • Published 1 year ago

@nettlelabs/nfd-lookup v1.1.0

Weekly downloads
-
License
GPL-2.0-or-later
Repository
github
Last release
1 year ago

Table of contents

📦 1. Installation

  • Using npm:
$ npm install @nettlelabs/nfd-lookup
  • Using yarn:
$ yarn add @nettlelabs/nfd-lookup

🪄 2. Usage

2.1 Quick Start

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
}

Back to top ^

2.2 API

lookupNfDomainByAddress(address, [options])

Lookup NFDomain metadata for an Algorand address (public key) on-chain.

Parameters

NameTypeDescription
addressstringThe Algorand address (public key) to lookup.

Options

An additional object must be provided:

NameTypeDefaultDescription
algodClientAlgodv2-An initialized Algod client that will be used to query the chain.
debugILogLevelsilentWhether logs will be printed to console. Can be one of debug, error, info, silent or warn. Defaults to silent.
registryAppIdbigint-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.

Returns

TypeDescription
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.

TypeScript Example

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: {}
}
*/

Back to top ^

🛠 3. Development

3.1. Requirements

Back to top ^

3.2. Setup

  1. Install the dependencies:
$ yarn install

Back to top ^

3.3. Build

  • To build simply run:
$ yarn build

This will compile the Typescript source code into a dist/ directory.

Back to top ^

📑 4. Appendix

4.1 Useful Information

Back to top ^

👏 5. How To Contribute

Please read the Contributing Guide to learn about the development process.

Back to top ^

📄 6. License

Please refer to the LICENSE file.

Back to top ^

🎉 7. Credits

  • A massive shout-out to TxnLab and the amazing work they are doing for the Algorand ecosystem. ❤️

Back to top ^

1.1.0

1 year ago

1.0.0

1 year ago