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

@w3tech.io/torpc-decoder

v0.1.0

Published

Reference TORPC codec: maps standard EVM JSON-RPC responses to the TORPC compact form and back. Structural only, no ABI resolution.

Downloads

31

Readme

@w3tech.io/torpc-decoder

Reference bidirectional mapper between standard EVM JSON-RPC responses and the TORPC (Token Optimized RPC) compact form. Structural only: no ABI resolution, no decoding of raw calldata or logs, no re-encoding. Producing the decoded {event, args} / {function, args} shapes is the server's job (spec tier T2). This library only reshapes what it is given.

npm install @w3tech.io/torpc-decoder
import { forward, backward } from '@w3tech.io/torpc-decoder';

The published package is built JavaScript with type declarations, not the TypeScript in src: Node does not strip types inside node_modules, so a .ts entry point cannot be imported. Inside a checkout the sources are imported directly, no build step needed.

import { forward, backward } from './src/index.ts';

const raw = { jsonrpc: '2.0', id: 1, result: '0x180fcbd' };
forward('eth_blockNumber', raw);   // → { jsonrpc, id, result: '25230525' }
backward('eth_blockNumber', { jsonrpc: '2.0', id: 1, result: '25230525' });
                                   // → { jsonrpc, id, result: '0x180fcbd' }

Normative reference, in the spec repository w3tech/torpc: specs/evm-v1.md for the tier mechanism and the T1 / T2 rules, and specs/methods/ for the per-field mapping of each method. Those documents are the source of truth; this library is one implementation of them.

How it works

  • forward (standard to compact): rename, hex to decimal, strip padding from indexed topics, drop service fields, apply EIP-55. If a log or transaction already carries provider-decoded fields (event / args / function), collapse it: keep the decoded shape, drop the now redundant raw topics / data / input.
  • backward (compact to standard): the mechanical inverse. Inverse renames, decimal to hex, re-pad topics, lowercase addresses.

Backward reverses only the mechanical mapping. A log or transaction that was decoded-and-collapsed on the way forward loses its raw topics / data / input permanently; backward returns the decoded fields plus the reversed structural fields. Lossy by design: logsBloom, cumulativeGasUsed, type, chainId, the signature fields v / r / s / yParity, and per-log redundant or service fields are dropped at T1 by the spec and are not restored. Clients that need them re-issue the request with no Accept-Token-Tier header and read the raw response.

Three levels

  1. primitives (src/primitives/): hexToDec / decToHex, stripZeroBlock / padZeroBlock, eip55 / lower, rename / drop, and the Field table engine that drives both directions from a single declaration.
  2. per-method (src/methods/): one module per method, wired into methods and then the registry. Unknown method means passthrough.
  3. batch (src/dispatch.ts): forwardBatch / backwardBatch. The caller supplies the method per element, because a JSON-RPC response does not carry one.

Method coverage

Every v1 method that has an entry under specs/methods/ in the spec repository:

| Module | Methods | |---|---| | hexInteger | eth_blockNumber, eth_chainId, eth_gasPrice, eth_maxPriorityFeePerGas, eth_blobBaseFee, eth_getBalance, eth_getTransactionCount, eth_estimateGas, eth_getBlockTransactionCountBy{Hash,Number}, eth_getUncleCountByBlock{Hash,Number} | | transactionReceipt | eth_getTransactionReceipt | | getLogs | eth_getLogs | | transactionByHash | eth_getTransactionByHash, eth_getTransactionByBlock{Hash,Number}AndIndex | | getBlockByHash | eth_getBlockByHash, eth_getBlockByNumber | | blockReceipts | eth_getBlockReceipts | | uncle | eth_getUncleByBlock{Hash,Number}AndIndex | | feeHistory | eth_feeHistory |

Any method not listed passes through untouched, which matches the spec: a method with no ruleset must be returned raw at Token-Tier: 0.

Development

Requires Node 22.6 or newer (native TS type stripping, no build step in dev).

npm install
npm test          # node --test
npm run typecheck # tsc --noEmit

Only runtime dependency: @noble/hashes, for keccak256 in EIP-55.

Licence

Apache-2.0. Copyright Web3 Technologies, Inc. (dba Ankr). Every file in this package is under that licence, and the full text is the LICENSE file at the root of w3tech/torpc-js.

The TORPC specification itself is published separately under CC0 1.0 in w3tech/torpc. CC0 waives the copyright in the specification text, which is what lets anyone reimplement the spec without permission or attribution. It is a copyright waiver and nothing more: it grants no patent rights and no trademark rights. For this code, the patent position is the express grant in Apache-2.0 §3, which is one reason the implementation is Apache-2.0 rather than CC0; the other is the contribution trail.