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 🙏

© 2024 – Pkg Stats / Ryan Hefner

libcrc7211

v0.1.6

Published

crc721 lib

Downloads

9

Readme

libcrc721

A Javascript library supports crc20 queries and crc721 badge queries.

Install

npm install libcrc721

or

yarn add libcrc721

Data Formats

Badge

export interface Badge {
  tokenId: string
  index: number
  owner: string
  badgeName: string
  info: {
    evmaddr?: string
    ipaddr?: string
    social?: string
    email?: string
    remark?: string
  }
}

BaseCRC20Token

export interface BaseCRC20Token {
    symbol: string
    category: string
    name: string
    decimals: number
    mintAmt: number
    totalSupply: number
    isCanonical: boolean
    revealHeight: number
}

CRC20Token

export interface CRC20Token extends BaseCRC20Token {
    type: "CRC20"
}

CRC721Token

export interface CRC721Token extends BaseCRC20Token {
    authorAddress: string
    baseTokenURI: string
    mintPrice: number
    feeCategory: string
    type: "CRC721"
}

CRCToken

export type CRCToken = CRC20Token | CRC721Token

Examples

async function addressToBadgeName(address: string): Promise<string>

import { addressToBadgeName } from 'libcrc721';
const result = await addressToBadgeName("bitcoincash:qqeht8vnwag20yv8dvtcrd4ujx09fwxwsqqqw93w88")
console.log(result)

async function badgeNameToAddress(badgeName: string): Promise<string>

import { badgeNameToAddress } from 'libcrc721';
const result = await badgeNameToAddress("xx-1")
console.log(result)

async function getTokensBySymbol(symbol: string): Promise<Array<CRC20Token | CRC721Token>>

import { getTokensBySymbol } from 'libcrc721';
const result = await getTokensBySymbol("TEST")
console.log(result)

async function getTokenByCategory(category: string): Promise<CRC20Token | CRC721Token>

import { getTokenByCategory } from 'libcrc721';
const result = await getTokenByCategory("548327f45d8ea815c32e3b60cc3ea8ad2120132ddf407420865502e1dd9ab161")
console.log(result)

async function getBadgesByAddress(owner: string): Promise<Badge[]>

import { getBadgesByAddress } from 'libcrc721';
const result = await getBadgesByAddress("bitcoincash:qqeht8vnwag20yv8dvtcrd4ujx09fwxwsqqqw93w88")
console.log(result)

async function getBadge(badgeName: string): Promise<Badge>

import { getBadge } from 'libcrc721';
const result = await getBadge("xx-1")
console.log(result)

function getBadgeName(symbol: string, index: number): string

import { getBadgeName } from 'libcrc721';
console.log(getBadgeName("xx", 0)) // xx
console.log(getBadgeName("xx", 1)) // xx-1

function splitBadgeName(badgeName: string): {string, number}

import { splitBadgeName } from 'libcrc721';
console.log(splitBadgeName("xx")) // {symbol:"xx",index:0}
console.log(getBadgeName("xx-1")) // {symbol:"xx",index:1}

Configs

Using customized Electrum URL

import { config } from 'libcrc721';
config.defaultElectrumClientUrl =  "wss://bch.imaginary.cash:50004"

Using Testnet

Note: The badgeTxQuerier must be customized when using testnet.

import { config } from 'libcrc721';
config.network = "testnet"

BadgeTxQuerier

The default badgeTxQuerier implements an interface to locate transaction ID by token category and commitment, which using Chaingraph.

Modify Chaingraph URL

import { mainnetChaingrapBadgeTxQuerier } from 'libcrc721';
mainnetChaingrapBadgeTxQuerier.defaultChaingraphUrl = "https://demo.chaingraph.cash/v1/graphql"

Customized BadgeTxQuerier

Users can query the transaction ID using their own API.

import { config,BadgeTxQuerier } from 'libcrc721';
const badgeTxQuerier:BadgeTxQuerier = {
    getTxId(tokenCategory: string, commitment: string){
        return fetch(<CUSTOMER_API_URL>)
    }
}
config.badgeTxQuerier = badgeTxQuerier