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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@1001-digital/resolve-metadata

v1.0.3

Published

Normalize NFT token and contract metadata into a strict typed schema.

Readme

@1001-digital/resolve-metadata

Normalize NFT metadata JSON (ERC-721, ERC-1155, contractURI) into a strict, typed schema. Pairs with @1001-digital/dweb-fetch — this package standardizes the JSON, dweb-fetch resolves the links.

Usage

import { resolveTokenMetadata, resolveContractMetadata } from '@1001-digital/resolve-metadata'

// Raw metadata from a tokenURI / uri response
const raw = {
  name: 'Cool NFT #42',
  description: 'A very cool NFT',
  image: 'https://gateway.pinata.cloud/ipfs/QmImage...',
  animation_url: 'https://arweave.net/txVideo...',
  background_color: '#FF0000',
  attributes: [
    { trait_type: 'Color', value: 'Blue' },
    { trait_type: 'Level', value: '7' },
  ],
}

const metadata = resolveTokenMetadata(raw)
// {
//   name: 'Cool NFT #42',
//   description: 'A very cool NFT',
//   image: 'ipfs://QmImage...',            ← gateway URL → protocol URI
//   animation_url: 'ar://txVideo...',       ← gateway URL → protocol URI
//   external_url: null,
//   background_color: 'ff0000',             ← normalized hex, no #
//   attributes: [
//     { trait_type: 'Color', value: 'Blue' },
//     { trait_type: 'Level', value: 7 },    ← numeric string → number
//   ],
//   decimals: null,
//   properties: null,
//   localization: null,
//   extra: {},
// }

// Contract-level metadata from contractURI
const contract = resolveContractMetadata({
  name: 'Cool Collection',
  description: 'A collection of cool NFTs',
  image: 'https://ipfs.io/ipfs/QmLogo...',
  banner_image: 'https://arweave.net/txBanner...',
  external_link: 'https://coolcollection.xyz',
  collaborators: ['0xABC...', '0xDEF...'],
  seller_fee_basis_points: 250,
})
// {
//   name: 'Cool Collection',
//   description: 'A collection of cool NFTs',
//   image: 'ipfs://QmLogo...',
//   banner_image: 'ar://txBanner...',
//   featured_image: null,
//   external_link: 'https://coolcollection.xyz',
//   collaborators: ['0xABC...', '0xDEF...'],
//   extra: { seller_fee_basis_points: 250 },
// }

URI Normalization

Gateway URLs are converted to protocol URIs. Links are not resolved — use dweb-fetch for that.

import { normalizeUri } from '@1001-digital/resolve-metadata'

normalizeUri('https://gateway.pinata.cloud/ipfs/QmXxx')  // → 'ipfs://QmXxx'
normalizeUri('https://bafyABC.ipfs.nftstorage.link')     // → 'ipfs://bafyABC'
normalizeUri('https://ipfs.io/ipns/example.eth')          // → 'ipns://example.eth'
normalizeUri('https://arweave.net/txId123')               // → 'ar://txId123'
normalizeUri('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz...')  // → 'ipfs://QmYwAPJzv5...'
normalizeUri('ipfs://QmXxx')                              // → 'ipfs://QmXxx' (passthrough)
normalizeUri('https://example.com/image.png')             // → 'https://example.com/image.png' (passthrough)

IPFS gateways are detected by path (/ipfs/, /ipns/) and subdomain (.ipfs., .ipns.) patterns, so any gateway works without a hardcoded list. Arweave gateways are matched by known hostnames (arweave.net, ar-io.dev, ar-io.net, arweave.dev).

What Gets Normalized

Token Metadata (ERC-721 + ERC-1155)

| What | How | |---|---| | URI fields (image, animation_url, external_url) | Gateway URLs → protocol URIs | | background_color | Strips #, expands 3-char to 6-char, lowercases | | Attributes [{ trait_type, value }] | Unified from multiple formats (see below) | | Numeric string attribute values ("42") | Coerced to numbers | | Field aliases (image_url, image_data, animation, external_link) | Mapped to canonical names | | ERC-1155 fields (decimals, properties, localization) | Extracted when present | | Unknown fields | Preserved in extra |

Contract Metadata (ERC-7572 / contractURI)

| What | How | |---|---| | URI fields (image, banner_image, featured_image) | Gateway URLs → protocol URIs | | collaborators | Validated as string array | | Field alias (external_url) | Mapped to external_link | | Unknown fields | Preserved in extra |

Attribute Format Handling

All of these are normalized to { trait_type: string, value: string | number }:

// Standard (ERC-721)
[{ trait_type: 'Color', value: 'Blue' }]

// With display hints
[{ trait_type: 'Level', value: 5, display_type: 'number', max_value: 10 }]

// Rarible-style (name instead of trait_type)
[{ name: 'Color', value: 'Blue' }]

// Plain object
{ Color: 'Blue', Rarity: 'Legendary' }

API

resolveTokenMetadata(input: unknown): TokenMetadata

Normalizes raw token metadata JSON. Accepts any value — returns typed output with null for missing fields, empty arrays for missing collections, and unknown fields in extra.

resolveContractMetadata(input: unknown): ContractMetadata

Normalizes raw contract/collection metadata JSON. Same guarantees as above.

normalizeUri(uri: string): string

Converts gateway URLs to protocol URIs. Returns the input unchanged if it is not a recognized gateway URL.

License

MIT