You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@web3-name-sdk/core

Package Overview
Dependencies
Maintainers
2
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3-name-sdk/core

One stop Web3 domain name resolution

0.0.1-beta.6
npmnpm
Version published
Weekly downloads
971
14.91%
Maintainers
2
Weekly downloads
 
Created
Source

web3-name-sdk

Web3 Name SDK is an universal web3 identity solution for domain name resolution. Developers can easily get access to .eth, .bnb, .arb, .lens, .crypto names and more.

Get Started

Developers can resolve web3 domain name or reverse resolve address with web3 name SDK with zero configuration.

Install

npm install @web3-name-sdk/core viem

Quick Start

1. Setup client

import { createWeb3Name } from '@web3-name-sdk/core'

const web3Name = createWeb3Name()

2. Resolve a domain name

You can get address from domain name with a single request:

const address = await web3name.getAddress('spaceid.bnb')
// expect: '0xb5932a6b7d50a966aec6c74c97385412fb497540'

const address = await web3name.getAddress('bts_official.lens')
// expect: '0xd80efa68b50d21e548b9cdb092ebc6e5bca113e7'

const address = await web3name.getAddress('beresnev.crypto')
// expect: '0x6ec0deed30605bcd19342f3c30201db263291589'

3. Resolve an address

There are optional parameters in the method to select your target chain or TLD (top-level domain).

By providing chain IDs, you can resolve addresses on selected chains and get an available domain name from all TLDs deployed on these chains.

// Resolve an address from BNB Chain
const name = await web3name.getDomainName({
  address: '0xb5932a6b7d50a966aec6c74c97385412fb497540',
  queryChainIdList: [56],
})
// expect: spaceid.bnb

By providing TLDs, address can be resolved from the selected TLDs and get an available TLD primary name.

// Resolve an address from BNB Chain
const name = await web3name.getDomainName({
  address: '0xb5932a6b7d50a966aec6c74c97385412fb497540',
  queryTldList: ['arb'],
})
// expect: spaceid.arb

4. Record

Domain text records can be fetched by providing domain name and the key. For example, the avatar record of spaceid.bnb is returned from this method given key name avatar:

const record = await sid.getDomainRecord({ name: 'spaceid.bnb', key: 'avatar' })

5. Metadata

Domain metadata can be fetched by SDK directly.

// Requestgin
const metadata = await web3Name.getMetadata({ name: 'foryou.kkk1' })

Non-EVM name services

As an all-in-one domain name SDK, non-EVM web3 domain name services are also included. Now we support SNS (Solana Name Service, .sol), Sei Name Service (.sei) and Injective Name Service (.inj).

1. Solana Name Service (.sol)

Install additional corresponding dependencies for Solana environment:

npm install @solana/web3 @bonfida/spl-name-service

Create client and query domains:

const web3Name = createSolName()
const domain = await web3Name.getDomainName({
  address: 'Crf8hzfthWGbGbLTVCiqRqV5MVnbpHB1L9KQMd6gsinb',
}) // expect: bonfida

2. Sei Name Service (.sei)

Install additional corresponding dependencies for Sei environment:

npm install @sei-js/core @siddomains/sei-sidjs

Create client and query domains:

const web3Name = createSeiName()
const domain = await web3Name.getDomainName({
  address: 'sei1tmew60aj394kdfff0t54lfaelu3p8j8lz93pmf',
}) // expect: allen.sei

3. Injective Name Service (.inj)

Install additional corresponding dependencies for Injective environment:

npm install @siddomains/injective-sidjs '@injectivelabs/networks' '@injectivelabs/ts-types'

Create client and query domains:

 const web3Name = createInjName()
const domain = await web3Name.getDomainName({
  address: 'inj10zvhv2a2mam8w7lhy96zgg2v8d800xcs7hf2tf',
}) // expect: testtest.inj

Keywords

eth

FAQs

Package last updated on 17 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts