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

@toon-protocol/core

v1.3.0

Published

Core library for Nostr-based ILP peer discovery and settlement

Downloads

359

Readme

@toon-protocol/core

Peer discovery, bootstrap, settlement negotiation, and TOON event encoding for the TOON Protocol network.

This is an internal package. Most users should start with @toon-protocol/client or @toon-protocol/sdk.

Install

npm install @toon-protocol/core

Key Exports

TOON Codec

Encode and decode Nostr events in the compact TOON binary format.

import { encodeEventToToon, decodeEventFromToon, shallowParseToon } from '@toon-protocol/core';

// Encode a Nostr event to TOON binary format
const toonBytes = encodeEventToToon(nostrEvent);

// Decode back to a Nostr event
const event = decodeEventFromToon(toonBytes);

// Fast metadata extraction without full decode
const meta = shallowParseToon(toonBytes);
console.log(meta.kind, meta.pubkey);

Peer Discovery

Discover ILP peers from Nostr relays, genesis nodes, or ArDrive registries.

import { NostrPeerDiscovery, GenesisPeerLoader, parseIlpPeerInfo } from '@toon-protocol/core';

// Query Nostr relays for kind:10032 peer info events
const discovery = new NostrPeerDiscovery({ relayUrls: ['wss://relay.example.com'] });
const peers = await discovery.query();

// Or load peers from a genesis node
const loader = new GenesisPeerLoader('http://localhost:3100');
const genesisPeers = await loader.load();

// Parse a raw Nostr event into typed peer info
const peerInfo = parseIlpPeerInfo(event);
console.log(peerInfo.ilpAddress, peerInfo.btpEndpoint);

Bootstrap Service

Orchestrates the full peer lifecycle: discovery, registration, settlement negotiation, and announcement.

import { BootstrapService } from '@toon-protocol/core';

const bootstrap = new BootstrapService(config);

bootstrap.addEventListener('phase', (e) => {
  console.log('Phase:', e.phase); // 'discovering' → 'registering' → 'announcing' → 'ready'
});

await bootstrap.start();

Compose API (Embedded Connector)

Wire a full TOON node with zero-latency embedded connector.

import { createToonNode } from '@toon-protocol/core';

const node = createToonNode({
  connector,
  secretKey,
  basePricePerByte: 10n,
  relayPort: 7100,
});

node.on(1, async (ctx) => {
  const event = ctx.decode();
  return ctx.accept();
});

await node.start();

Event Builders

Build typed Nostr events for ILP peer info, service discovery, seed relay lists, and TEE attestation.

import {
  buildIlpPeerInfoEvent,
  buildServiceDiscoveryEvent,
  buildAttestationEvent,
  buildJobRequestEvent,
} from '@toon-protocol/core';

Chain Configuration

Resolve chain presets for settlement (Anvil, Arbitrum Sepolia, Arbitrum One).

import { resolveChainConfig, CHAIN_PRESETS } from '@toon-protocol/core';

const chain = resolveChainConfig('arbitrum-sepolia');
console.log(chain.chainId, chain.usdcAddress);

Settlement Negotiation

Find a common settlement chain between two peers.

import { negotiateSettlementChain } from '@toon-protocol/core';

const chain = negotiateSettlementChain(peerInfo, localConfig);

Full API

| Category | Exports | |----------|---------| | Codec | encodeEventToToon, decodeEventFromToon, shallowParseToon, encodeEventToToonString | | Discovery | NostrPeerDiscovery, GenesisPeerLoader, ArDrivePeerRegistry, SocialPeerDiscovery, SeedRelayDiscovery | | Bootstrap | BootstrapService, createDiscoveryTracker | | Compose | createToonNode, ToonNode, EmbeddableConnectorLike | | Events | buildIlpPeerInfoEvent, buildServiceDiscoveryEvent, buildAttestationEvent, buildSeedRelayListEvent | | DVM | buildJobRequestEvent, buildJobResultEvent, buildJobFeedbackEvent, parseJobRequest/Result/Feedback | | Chain | resolveChainConfig, CHAIN_PRESETS, buildEip712Domain, validateChainId | | Settlement | negotiateSettlementChain, resolveTokenForChain | | TEE | AttestationVerifier, AttestationState, AttestationBootstrap, deriveFromKmsSeed | | ILP Clients | createDirectIlpClient, createHttpIlpClient, createDirectConnectorAdmin, createHttpConnectorAdmin | | Errors | ToonError, InvalidEventError, PeerDiscoveryError, ToonEncodeError, ToonDecodeError | | Logging | createLogger, LogLevel |

License

MIT