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/natspec

v0.1.0

Published

Fetch and normalize NatSpec (userdoc/devdoc) documentation from [Sourcify](https://sourcify.dev) for any verified smart contract.

Readme

@1001-digital/natspec

Fetch and normalize NatSpec (userdoc/devdoc) documentation from Sourcify for any verified smart contract.

Install

pnpm add @1001-digital/natspec

Usage

Fetch NatSpec from Sourcify

import { createNatSpec } from '@1001-digital/natspec'

const natspec = createNatSpec()

// Fetch + parse in one step
const result = await natspec.fetch(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')

console.log(result.functions.deposit)
// {
//   signature: 'deposit()',
//   name: 'deposit',
//   notice: 'Deposit ETH and receive WETH',
// }

Parse raw userdoc/devdoc

If you already have the userdoc and devdoc (e.g. from compiler output), use parse directly:

import { parse } from '@1001-digital/natspec'

const result = parse(userdoc, devdoc)

Convert to contract-metadata format

Convert parsed NatSpec to a shape compatible with the contract-metadata standard:

import { createNatSpec } from '@1001-digital/natspec'

const natspec = createNatSpec()
const result = await natspec.fetch(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
const metadata = natspec.toMetadata(result)

console.log(metadata.functions?.deposit)
// {
//   description: 'Deposit ETH and receive WETH',
// }

API

createNatSpec(config?)

Creates a NatSpec client.

Config options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseUrl | string | 'https://sourcify.dev/server' | Sourcify API base URL | | fetch | typeof fetch | globalThis.fetch | Custom fetch function |

Returns a NatSpecClient with:

  • fetch(chainId, address) — Fetches userdoc + devdoc from Sourcify and returns normalized NatSpec
  • parse(userdoc, devdoc) — Pure function. Merges raw userdoc/devdoc into normalized NatSpec
  • toMetadata(natspec) — Pure function. Converts NatSpec to NatSpecMetadata (contract-metadata compatible)

parse(userdoc, devdoc)

Also exported directly for standalone use without the factory.

toMetadata(natspec)

Also exported directly for standalone use.

Output shapes

NatSpec (normalized intermediate)

{
  contract?: { title?, author?, notice?, details? }
  functions: Record<string, {
    signature: string      // e.g. 'transfer(address,uint256)'
    name: string           // e.g. 'transfer'
    notice?: string        // from @notice (user-facing)
    details?: string       // from @dev (developer-facing)
    params?: Record<string, string>
    returns?: Record<string, string>
  }>
  events: Record<string, { ... }>   // same shape minus returns
  errors: Record<string, { ... }>   // same shape minus returns
}

NatSpecMetadata (contract-metadata compatible)

{
  functions?: Record<string, {
    description?: string
    params?: Record<string, { description: string }>
    returns?: Record<string, { description: string }>
  }>
  events?: Record<string, { ... }>
  errors?: Record<string, { ... }>
}

Overloaded functions

Functions with the same name but different parameters use the full Solidity signature as key:

result.functions['safeTransferFrom(address,address,uint256)']
result.functions['safeTransferFrom(address,address,uint256,bytes)']

Non-overloaded functions use the bare name:

result.functions['transfer']

License

MIT