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

@pulsadev/tx-decoder

v0.1.0

Published

Decode any EVM transaction calldata into human-readable format — with or without an ABI

Readme

@pulsadev/tx-decoder

Decode any EVM transaction calldata into human-readable format — with or without an ABI.

Pass calldata and get back the function name, signature, and decoded arguments. If you don't have the ABI, the package automatically queries 4byte.directory to resolve the selector. Zero dependencies.

Features

  • ABI-optional decoding — provide an ABI for exact decoding, or let 4byte.directory resolve unknown selectors
  • Calldata decoding — function name, signature, and decoded arguments from raw calldata
  • Event log decoding — decode indexed and non-indexed parameters from transaction logs
  • Error decoding — Error(string), Panic(uint256), and custom ABI errors
  • Sync + async APIdecodeCalldataSync for known ABIs, decodeCalldata for automatic lookup
  • 4byte.directory integration — automatic selector and event topic resolution with built-in caching
  • Zero dependencies — pure TypeScript, ~25 KB bundled, ESM + CJS
  • Works everywhere — Node.js, Deno, Bun, browsers

Install

npm install @pulsadev/tx-decoder

Quick Start

With ABI (synchronous)

import { decodeCalldataSync } from '@pulsadev/tx-decoder'

const abi = [{
  type: 'function',
  name: 'transfer',
  inputs: [
    { type: 'address', name: 'to' },
    { type: 'uint256', name: 'amount' },
  ],
  outputs: [{ type: 'bool', name: '' }],
  stateMutability: 'nonpayable',
}]

const result = decodeCalldataSync(calldata, abi)
// {
//   selector: '0xa9059cbb',
//   signature: 'transfer(address,uint256)',
//   functionName: 'transfer',
//   args: { to: '0xd8dA...6045', amount: 1000000n },
//   rawArgs: ['0xd8dA...6045', 1000000n]
// }

Without ABI (automatic 4byte lookup)

import { decodeCalldata } from '@pulsadev/tx-decoder'

// No ABI needed — selector is resolved via 4byte.directory
const result = await decodeCalldata(calldata)
// {
//   selector: '0xa9059cbb',
//   signature: 'transfer(address,uint256)',
//   functionName: 'transfer',
//   args: { param0: '0xd8dA...6045', param1: 1000000n },
//   rawArgs: ['0xd8dA...6045', 1000000n]
// }

API

Calldata Decoding

// Async — auto-resolves unknown selectors via 4byte.directory
const result = await decodeCalldata(data, {
  abi?: AbiItem[],          // optional ABI (tried first)
  fetchSignature?: boolean, // enable/disable 4byte lookup (default: true)
  fourByteUrl?: string,     // custom 4byte API URL
})

// Sync — requires ABI, no network calls
const result = decodeCalldataSync(data, abi)

Event Log Decoding

import { decodeLog, decodeLogSync } from '@pulsadev/tx-decoder'

// Async — with optional 4byte topic lookup
const event = await decodeLog(log.topics, log.data, { abi })
// { eventName: 'Transfer', signature: 'Transfer(address,address,uint256)', args: { from, to, value } }

// Sync — requires ABI
const event = decodeLogSync(log.topics, log.data, abi)

Error Decoding

import { decodeError } from '@pulsadev/tx-decoder'

const error = await decodeError(revertData, { abi })
// Built-in: { errorName: 'Error', args: { reason: 'Insufficient balance' } }
// Panic:   { errorName: 'Panic', args: { code: 0x11n, reason: 'Arithmetic overflow/underflow' } }
// Custom:  { errorName: 'InsufficientOutputAmount', args: { amountOut: 500n, amountOutMin: 1000n } }

4byte.directory Lookup

import { lookupSelector, lookupEventTopic } from '@pulsadev/tx-decoder'

// Lookup function signature by selector
const entries = await lookupSelector('a9059cbb')
// [{ name: 'transfer', signature: 'transfer(address,uint256)', inputs: [...] }]

// Lookup event signature by topic hash
const events = await lookupEventTopic('0xddf252ad...')

Utilities

import { keccak256, selector, eventTopic } from '@pulsadev/tx-decoder'

keccak256('transfer(address,uint256)')     // full 32-byte hash
selector('transfer(address,uint256)')      // first 4 bytes
eventTopic('Transfer(address,address,uint256)') // '0x' + full hash

Why @pulsadev/tx-decoder

| | @pulsadev/tx-decoder | abi-decoder | whatsabi | ethers/viem | |--|:--:|:--:|:--:|:--:| | ABI-optional decoding | ✅ | ❌ | ❌ | ❌ | | 4byte.directory auto | ✅ | ❌ | ❌ | ❌ | | Calldata decoding | ✅ | ✅ | ❌ | ✅ | | Event decoding | ✅ | ✅ | ❌ | ✅ | | Error decoding | ✅ | ❌ | ❌ | partial | | Standalone | ✅ 0 deps | ❌ web3 | ✅ | ❌ | | TypeScript | ✅ | ❌ | ✅ | ✅ | | MIT license | ✅ | ❌ GPL | ✅ | ✅ | | ESM + CJS | ✅ | ❌ CJS | ✅ | ✅ | | Maintained | ✅ | ❌ 5yr | ✅ | ✅ |

License

MIT © Yuto Nakamura