npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ju-space-id-sdk

v1.0.4

Published

DID SDK for SID

Readme

JU DID SDK

这是一个用于与 JU Chain 交互的 SDK,提供了域名解析和地址映射等功能。

安装

npm install ju-space-id-sdk

依赖要求

  • web3.js: ^1.10.0

使用方法

初始化

const SDK = require('ju-space-id-sdk')
const sdk = SDK('https://rpc.juchain.org')

主要功能

1. 获取域名对应的 TokenId

const juName = 'junames.ju'
const tokenId = await sdk.SIDRegistry.getTokenId(juName)

2. 域名解析到地址

const chainId = '0x33450'
const addr = await sdk.nameToAddr(chainId, juName)

3. 地址反向解析到域名

const name = await sdk.addrToName(chainId, addr)

4. TokenId 解析到域名

const contractAddress = '0x3972ff9AF27c07826895E45CAFD5b22279508C99'
const tname = await sdk.tokenIdToName(chainId, contractAddress, tokenId)

配置参数

  • chainId: JU Chain 的链 ID,默认为 '0x33450'
  • juContractAddress: JU 合约地址
  • aicContractAddress: AIC 合约地址

错误处理

所有方法都使用 try-catch 进行错误处理,建议在使用时进行适当的错误捕获:

try {
  // SDK 操作
} catch (error) {
  console.log(error)
}

示例代码

完整的示例代码。

const chainId = '0x33450'
const juContractAddress = '0x3972ff9AF27c07826895E45CAFD5b22279508C99'
const aicContractAddress = '0x7b18dE01cf67cd970Da499e2dA65292688d25Fd4'
async function main() {
  try {
    const sdk = SDK('https://rpc.juchain.org')
    const juName = 'junames.ju' //'junames.aic'
    const tokenId = await sdk.SIDRegistry.getTokenId(juName)
    const addr = await sdk.nameToAddr(chainId, juName)
    console.log('tokenId', BigInt(tokenId).toString())
    console.log('指向地址', addr)
    const name = await sdk.addrToName(chainId, addr)
    console.log('主域名', name)
    // //
    console.log('开始计算 TokenId:', tokenId)
    const contractAddress = juContractAddress
    const tname = await sdk.tokenIdToName(chainId, contractAddress, tokenId)
    console.log('TokenId计算域名:', tname)
  } catch (error) {
    console.log(error)
  }
}