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 🙏

© 2025 – Pkg Stats / Ryan Hefner

openintents-storage-proof-generator

v1.0.3

Published

Generate Ethereum storage proofs for cross-chain verification

Readme

openintents-storage-proof-generator

Generate Ethereum storage proofs for cross-chain verification. Works in Node.js and browser environments.

Installation

npm install openintents-storage-proof-generator
# or
yarn add openintents-storage-proof-generator
# or
pnpm add openintents-storage-proof-generator

Usage

As a Library (Browser & Node.js)

import { generateStorageProof } from 'openintents-storage-proof-generator';

const proof = await generateStorageProof({
  rpc: 'https://rpc.example.com',
  account: '0x1234567890123456789012345678901234567890',
  slot: 0n, // Storage slot as bigint
  blockNumber: 12345678n,
});

console.log(proof);
// {
//   blockNumber: '0xbc614e',
//   blockHash: '0x...',
//   stateRoot: '0x...',
//   account: '0x1234...',
//   slot: '0x0000...0000',
//   slotValue: '0x...',
//   rlpBlockHeader: '0x...',
//   rlpAccountProof: '0x...',
//   rlpStorageProof: '0x...',
// }

Reusable Generator Instance

For generating multiple proofs against the same RPC:

import { createProofGenerator } from 'openintents-storage-proof-generator';

const generator = createProofGenerator('https://rpc.example.com');

const proof1 = await generator.generate({
  account: '0x1234...',
  slot: 0n,
  blockNumber: 12345678n,
});

const proof2 = await generator.generate({
  account: '0x5678...',
  slot: 1n,
  blockNumber: 12345678n,
});

Node.js File Utilities

import { generateAndSaveProof, loadProof } from 'openintents-storage-proof-generator/node';

// Generate and save to file
await generateAndSaveProof(
  {
    rpc: 'https://rpc.example.com',
    account: '0x1234...',
    slot: 0n,
    blockNumber: 12345678n,
  },
  './proof.json'
);

// Load from file
const proof = loadProof('./proof.json');

CLI

# Install globally
npm install -g openintents-storage-proof-generator

# Generate proof
storage-proof-generator \
  --rpc "https://rpc.example.com" \
  --account "0x1234567890123456789012345678901234567890" \
  --slot "0" \
  --block "12345678" \
  --output "proof.json"

API Reference

generateStorageProof(options)

Generates a complete storage proof for cross-chain verification.

Parameters:

  • options.rpc - RPC endpoint URL
  • options.account - Account address to prove storage for
  • options.slot - Storage slot (as bigint)
  • options.blockNumber - Block number to generate proof at (as bigint)

Returns: Promise<StorageProof>

createProofGenerator(rpc)

Creates a reusable proof generator instance.

Parameters:

  • rpc - RPC endpoint URL

Returns: Object with generate() method and getClient() method

Types

interface StorageProof {
  blockNumber: Hex;
  blockHash: Hex;
  stateRoot: Hex;
  account: string;
  slot: Hex;
  slotValue: Hex;
  rlpBlockHeader: Hex;
  rlpAccountProof: Hex;
  rlpStorageProof: Hex;
  sendRoot?: Hex; // For Arbitrum-style chains
}

interface ProofGeneratorOptions {
  rpc: string;
  account: `0x${string}`;
  slot: bigint;
  blockNumber: bigint;
}

How It Works

  1. Fetch Block Header - Gets the block header at the specified block number
  2. RLP Encode - Encodes the block header using RLP (tries debug_getRawHeader first, falls back to manual encoding)
  3. Verify Block Hash - Ensures keccak256(rlpBlockHeader) === blockHash
  4. Generate Merkle Proofs - Uses eth_getProof to get account and storage proofs
  5. Verify State Root - Ensures computed state root matches block header

Cross-Chain Verification

The generated proof can be used on-chain to verify storage values from another chain:

// On-chain verification (simplified)
function verifyStorageProof(
    bytes32 trustedBlockHash,
    bytes calldata rlpBlockHeader,
    bytes calldata rlpAccountProof,
    bytes calldata rlpStorageProof
) external view returns (bytes32 value) {
    // 1. Verify block header hashes to trusted hash
    require(keccak256(rlpBlockHeader) == trustedBlockHash);

    // 2. Extract state root from block header
    bytes32 stateRoot = extractStateRoot(rlpBlockHeader);

    // 3. Verify account proof against state root
    bytes32 storageRoot = verifyAccountProof(rlpAccountProof, stateRoot);

    // 4. Verify storage proof against storage root
    value = verifyStorageProof(rlpStorageProof, storageRoot);
}

Supported Networks

Works with any EVM-compatible chain that supports:

  • eth_getBlockByNumber
  • eth_getProof

Optionally uses debug_getRawHeader for more accurate block header encoding.

License

MIT