You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@pinax/graph-networks-registry

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinax/graph-networks-registry

TypeScript types and helpers for The Graph Networks Registry

0.7.1
latest
Source
npmnpm
Version published
Maintainers
5
Created
Source

The Graph Networks Registry Typescript Library

npm version Documentation License: MIT

TypeScript types and helpers for The Graph Networks Registry.

Documentation available here.

Installation

npm install @pinax/graph-networks-registry

Usage

Loading the Registry

import { NetworksRegistry } from '@pinax/graph-networks-registry';

// Load from the latest compatible registry JSON at networks-registry.thegraph.com
const registry = await NetworksRegistry.fromLatestVersion();

// Load from specific version tag at networks-registry.thegraph.com
const registry = await NetworksRegistry.fromExactVersion('0.7.0');
const registry = await NetworksRegistry.fromExactVersion('0.7.x');

// Load from URL
const registry = await NetworksRegistry.fromUrl('https://networks-registry.thegraph.com/TheGraphNetworksRegistry.json');

// Load from local file
const registry = NetworksRegistry.fromFile('./TheGraphNetworksRegistry.json');

// Load from JSON string
const registry = NetworksRegistry.fromJson(jsonString);

Working with Networks

// Find network by graph ID (works with both network ID and alias)
const mainnet = registry.getNetworkByGraphId('mainnet');
if (mainnet) {
    console.log(mainnet.fullName); // "Ethereum Mainnet"
    console.log(mainnet.caip2Id); // "eip155:1"
}

// You can also use an alias with getNetworkByGraphId
const ethereum = registry.getNetworkByGraphId('eth');
if (ethereum) {
    console.log(ethereum.fullName); // "Ethereum Mainnet"
}

// Find network by CAIP-2 chain ID
const ethereumByChainId = registry.getNetworkByCaip2Id('eip155:1');
if (ethereumByChainId) {
    console.log(ethereumByChainId.fullName); // "Ethereum Mainnet"
    console.log(ethereumByChainId.id); // "mainnet"
}

// Invalid format will produce a warning and return undefined
const invalidNetwork = registry.getNetworkByCaip2Id('invalid-format');
// Warning: CAIP-2 Chain ID should be in the format '[namespace]:[reference]', e.g., 'eip155:1'

// Deprecated methods (will be removed in future versions)
// Find network by ID
// @deprecated Use getNetworkByGraphId instead
const mainnetById = registry.getNetworkById('mainnet');

// Find network by alias
// @deprecated Use getNetworkByGraphId instead
const mainnetByAlias = registry.getNetworkByAlias('eth');

Keywords

graph

FAQs

Package last updated on 03 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts