diff --git a/.gitbook/contracts/injective-name-service.md b/.gitbook/contracts/injective-name-service.md index b37472767..fd70810bf 100644 --- a/.gitbook/contracts/injective-name-service.md +++ b/.gitbook/contracts/injective-name-service.md @@ -1,8 +1,28 @@ # Injective Name Service -Within this section we are going to have a look how to query the Injective name service contracts. +Within this section, we will look at how to query the Injective name service contracts. -## Querying +## Abstraction Service + +You can use our `InjNameService` [abstraction](../../packages/sdk-ui-ts/src/services/nameservice/InjNameService.ts) to query the smart contracts with a single method call. Below this example, you can also find the raw implementation on how to query the smart contracts in case you need more flexibility.  + +<pre class="language-typescript"><code class="lang-typescript">import { getNetworkEndpoints, Network } from '@injectivelabs/network' +import { InjNameService } from '@injectivelabs/sdk-ui-ts' + +(async (){ + const injNameService = new InjNameService(Network.Testnet) + +<strong> const name = 'ninja.inj' +</strong> + // Fetch the address for the particular name + const address = await injNameService.fetchInjAddress(name) + + // Fetch the name for the particular address + const nameFromAddress = await injNameService.fetchInjName(address) +})() +</code></pre> + +## Raw Smart Contract Querying Example code snippets to resolve .inj domain name.