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

@foodxdev/foodblock

v0.5.0

Published

SDK for the FoodBlock protocol — a content-addressable primitive for universal food data

Downloads

385

Readme

@foodxdev/foodblock

SDK for the FoodBlock Protocol — a content-addressable data primitive for universal food data.

Install

npm install @foodxdev/foodblock

Quick Start

const { create, update, chain } = require('@foodxdev/foodblock')

// Create a block
const farm = create('actor.producer', { name: 'Green Acres Farm' })
// => { hash: 'a1b2c3...', type: 'actor.producer', state: {...}, refs: {} }

// Create with references
const bread = create('substance.product', { name: 'Sourdough', price: 4.50 }, {
  seller: farm.hash
})

// Update a block (creates a new block referencing the previous)
const updated = update(bread.hash, 'substance.product', { name: 'Sourdough', price: 5.00 })
// updated.refs.updates === bread.hash

// Follow the provenance chain
const history = await chain(updated.hash, async (hash) => {
  // your resolver: fetch block by hash from DB/API
  return await fetch(`/blocks/${hash}`).then(r => r.json())
})

Base Types

FoodBlock defines 6 base types. Subtypes use dot notation (e.g. actor.producer).

| Type | Description | |------|-------------| | actor | People, orgs, devices, agents | | place | Locations, facilities, appliances | | substance | Ingredients, products, materials | | transform | Processes that change substances | | transfer | Movement of substances between actors | | observe | Reviews, scans, certifications |

API

create(type, state?, refs?)

Create a new FoodBlock. Returns { hash, type, state, refs }.

  • type — string, required (e.g. 'substance.product')
  • state — object, the block's data
  • refs — object, references to other blocks by hash

The hash is SHA-256(canonical(type + state + refs)) — deterministic and content-addressable.

update(previousHash, type, stateChanges?, additionalRefs?)

Create an update block that supersedes a previous block. Adds refs.updates pointing to the previous hash.

hash(type, state?, refs?)

Compute the SHA-256 hash without creating a full block object.

canonical(type, state, refs)

Produce the deterministic canonical JSON string used for hashing.

chain(startHash, resolve, opts?)

Follow the updates chain backwards. resolve is async (hash) => block | null. Returns array from newest to oldest.

tree(startHash, resolve, opts?)

Follow ALL refs recursively to build the full provenance tree.

generateKeypair()

Generate an Ed25519 keypair for signing. Returns { publicKey, privateKey } as hex strings.

sign(block, authorHash, privateKeyHex)

Sign a block. Returns { foodblock, author_hash, signature }.

verify(wrapper, publicKeyHex)

Verify a signed block wrapper. Returns true or false.

createAgent(name, operatorHash, opts?)

Create an AI agent identity with its own keypair. Returns an agent object with a .sign() method.

Canonical Form Rules

  1. Keys sorted lexicographically at every nesting level
  2. No whitespace
  3. Numbers: no trailing zeros, no leading zeros
  4. Strings: Unicode NFC normalization
  5. Arrays in refs: sorted lexicographically (set semantics)
  6. Arrays in state: preserve declared order (sequence semantics)
  7. Null values: omitted

Sandbox

Try the live sandbox at api.foodx.world/foodblock

License

MIT