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

@searchboxlabs/metalayer

v1.0.11

Published

Verifiable Onchain Metadata for 0G Storage Store, verify, and fetch file contexts directly from the blockchain.

Readme

🧱 MetaLayer SDK

Verifiable Onchain Metadata for 0G Storage
Store, verify, and fetch file contexts directly from the blockchain.

npm version Build 0G Network


🌐 Overview

MetaLayer provides a lightweight SDK for working with onchain-aware metadata stored on the 0G Storage Network.

It enables:

  • Seamless uploading of files with verifiable Merkle roots.
  • Storing & retrieving contextual metadata onchain.
  • Integration with decentralized indexers.
  • Easy browser & backend usage.

⚙️ Installation

npm install @searchboxlabs/[email protected]

or with Yarn:

yarn add @searchboxlabs/[email protected]

🚀 Quick Start

import MetaLayerClient from "@metalayer/metalayer";
import { NETWORKS } from "@metalayer/metalayer/dist/network";
import { Blob, Indexer } from "@0glabs/0g-ts-sdk";
import { ethers } from "ethers";
import fs from "fs/promises";

async function main() {
  const client = new MetaLayerClient();
  const indexer = new Indexer(NETWORKS.testnet.indexerUrl);

  const ctx = {
    fileType: "text",
    extension: ".txt",
    dateAdded: BigInt(Date.now()),
    encrypted: false,
    creator: "0x330cA32b71b81Ea2b1D3a5C391C5cFB6520E0A10"
  };

  const buffer = await fs.readFile("./test.txt");
  const file = {
    size: buffer.length,
    slice: (start: number, end: number) => ({
      arrayBuffer: async () => buffer.slice(start, end).buffer,
    }),
  };

  const provider = new ethers.JsonRpcProvider(NETWORKS.testnet.rpcUrl);
  const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

  await client.uploadWithCtx(indexer, ctx, file, NETWORKS.testnet, signer);

  const blob = new Blob(file);
  const [tree] = await blob.merkleTree();
  const rootHash = tree?.rootHash();

  const encodedCtx = await client.getOnchainAwareCtx(rootHash, NETWORKS.testnet, signer);
  console.log(client.decodeOGFileCtx(encodedCtx));
}

main();

🧩 Smart Contract

The onchain contract powering MetaLayer lives here: 🔗 MetaLayer.sol

It defines:

  • getCtx(bytes32 rootHash) view returns (bytes)
  • storeCtx(bytes32 rootHash, bytes memory ctx)

This allows verified metadata retrieval from smart contracts or external SDKs.


🔗 Integration Example

You can see an example integration using this SDK here: 📂 MetaLayer Integration Code


🧠 Network Configuration

export const NETWORKS: Record<string, NetworkConfig> = {
  testnet: {
    name: 'testnet',
    rpcUrl: 'https://evmrpc-testnet.0g.ai/',       // <- change if you have a different RPC
    indexerUrl: 'https://indexer-storage-testnet-turbo.0g.ai/', // <- change to the real indexer endpoint
    explorerUrl: 'https://chainscan-galileo.0g.ai/',
    chainId: 16602,
    metaLayerAddress: `0x${"3Ca8B5e3fCD85c9960C3F8c09f0cbe6145ccdC27"}`
  },
  mainnet: {
    name: 'mainnet',
    rpcUrl: 'https://evmrpc.0g.ai/',       // <- change if you have a different RPC
    indexerUrl: 'https://indexer-storage-turbo.0g.ai/', // <- change to the real indexer endpoint
    explorerUrl: 'https://chainscan.0g.ai/',
    chainId: 16661,
    metaLayerAddress: `0x${"0xd15f8fc862d29b19d8f614c4aceb727f67986677"}`
  },
};

🛠️ Development

To build from source:

git clone https://github.com/s29papi/MetaLayer.git
cd MetaLayer
npm install
npm run build

The compiled SDK will appear under:

dist/

🤝 Contributing

Pull requests and ideas are welcome! Please open an issue before submitting large changes.


🪪 License

This project is licensed under the ISC License. See LICENSE for details.