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

@monsterdomains/midjs

v0.0.1-alpha.44

Published

midjs makes Monster domain easy to be integrated

Downloads

105

Readme

Monster Domains TypeScript SDK

Monster Domains JavaScript SDK provides a way for developers to integrate the features and abilities in Monster Domains system with easy-to-use TypeScript interfaces.

Installation

npm install @monsterdomains/midjs@latest --save

or

yarn add @monsterdomains/midjs@latest

Example Usage

Set up the MID SDK with proper provider, or signer if you need to send transactions

import MID from "@monsterdomains/midjs";

const NETWORK_ID: number = xxx; // We are a cross-chain domain service, supported network IDs: 56
const provider: ethers.providers.Provider = xxxx;
const signer: ethers.Signer = xxxx;

// @NOTE: if the signer is undefined, you can't use the SDK to send transactions
const mid = new MID({ provider, signer, networkId: NETWORK_ID });

// Now you can call the functions on `mid`
...

You can query the basic mapping relations between names and addresses with SDK instance

...

await mid.getAddressByName("goodname.bnb"); // ==> "0x123..."
await mid.setAddressByName("goodname.bnb", "0x123123...") // You must be the owner of "goodname.bnb" to make this work

await mid.getOwnerByName("goodname.bnb"); // ==> "0x456..."
await mid.setOwnerByName("goodname.bnb", "0x678..."); // ==> You must be the owner of "goodname.bnb" to make this work

await mid.available("goodname.bnb"); // if a domain is taken, it will return `false`
...

You can also get the ethers contract instances if you want to make the low level calls by yourself and don't need to deal with the troublesome ABI files and contract initializations.

mid.mid; // The registry contract that stores all the data of nodes, which are the name hash of domain names, and their related owners
mid.controller; // Registrar controller instance for users to interact with
mid.baseRegistrar; // BaseRegistrar instances which is in charge of 'bnb' domain allocation and also the NFT contract
mid.publicResolver; // Public resolver for resolving names and their related metadata like texts, contents & addresses
mid.reverseRegistrar; // Reverse registrar for recording the primary name of domain names

API References

  • Get the owner of name
getOwnerByName(name: string) => Promise<string>
  • Set the owner of name, you must be the owner of the domain name to call this function
setOwnerByName(name: string, address: string) => Promise<void>
  • Get the resolver of name
getResolverByName(name: string) => Promise<string>
  • Set the resolver for name, you must be the owner of the domain name to call this function
setResolverByName(name: string, address: string) => Promise<void>
  • Get the TTL (Time To Live) of name
getTTLByName(name: string) => Promise<ethers.BigNumber>
  • Get the address of name. If coinType is not provided, it will be set to BNB coin type
getAddressByName(name: string, coinType?: CoinType) => Promise<string>
  • Batch call getAddressByName for name
getAddressesByName(name: string, coinTypes: (CoinType | undefined)[]) => Promise<string[]>
  • Set the address for name. If coinType is not provided, it will be set to BNB coin type
setAddressByName(name: string, coinType: string, address: string)
  • Batch set the addresses for name
setAddressesByName(name: string, keys: string[], addresses: string[])
  • Get the content of name. The returned value is the link pointing to the content, e.g: ipfs://xxxxxyyyyy...
getContentByName(name: string) => Promise<string>
  • Set the content for name
setContentByName(name: string, content: string)
  • Get the text of name
getTextByName(name: string, key: string)  => Promise<string>
  • Batch call getTextByName
getTextsByName(name: string, keys: string[]) => Promise<string[]>
  • Set text for name. You can specify the key for recordValue
setTextByName(name: string, key: string, recordValue: string)
  • Batch call setTextByName
setTextsByName(name: string, keys: string[], recordValues: string[])
  • Set subnode owner for name. The label is the keccak hash of subdomain name. For example: By calling setSubnodeOwnerByName(namehash("good.bnb"), keccak256("sub"), newOwner), you can set the owner of name: "sub.good.bnb" to newOwner. You must be owner of the "good.bnb" to call this function
setSubnodeOwnerByName(name: string, label: string, newOwner: string)
  • Create subdomain ${label}.${name} for the name domain, the label is the keccak256 hash of subdomain name
createSubdomainByName(name: string, label: string)
  • Delete the subdomain ${label}.${name} of the name domain, the label is the keccak256 hash of subdomain name
deleteSubdomainByName(name: string, label: string)
  • Check whether a name is available
available(name: string) => Promise<boolean>
  • Get the primary name of address
getPrimaryName(address: string) => Promise<string>
  • Set the primary name for address
setPrimaryName(name: string)
  • Get the expire date of name
getNameExpiry(name: string) => Promise<ethers.BigNumber>