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

@bradthomasbrown/abi

v1.0.0

Published

Minimal, unoptimized, unaudited, and experimental ABI encoder/decoder library in JavaScript/TypeScript.

Readme

abi

This is a simple, minimal implementation of Ethereum ABI encoding and decoding in TypeScript/JavaScript.

Installation

npm i @bradthomasbrown/abi

Usage

/* Example ABI with an overload
[
	{
		"inputs": [
			{
				"internalType": "uint256",
				"name": "a",
				"type": "uint256"
			}
		],
		"name": "_df639c_",
		"outputs": [
			{
				"internalType": "uint256",
				"name": "value",
				"type": "uint256"
			}
		],
		"stateMutability": "pure",
		"type": "function"
	},
	{
		"inputs": [
			{
				"internalType": "string",
				"name": "a",
				"type": "string"
			}
		],
		"name": "_df639c_",
		"outputs": [
			{
				"internalType": "string",
				"name": "text",
				"type": "string"
			}
		],
		"stateMutability": "pure",
		"type": "function"
	}
]
*/

import { encode, decode, _655c97_, _869645_ } from "@bradthomasbrown/abi";
import * as _0b1577_ from "./0b1577/dist/0b1577";

function bufferToHex(buffer:ArrayBuffer):string {
    return new Uint8Array(buffer).toHex();
}

// these first usage examples are how to use `abi` in a low-level and direct way 

const abiJson = await Bun.file("./test/0b1577/src/0b1577.abi").json();
const _0a_ = abiJson[0]; // get the first abi fragment, the uint overload
const _6d_ = [0x123456789n]; // an array of values to be used in ABI encoding
const _aa_ = _655c97_(_0a_, "inputs"); // builds a "first pass" metadata tree
const _56_ = _869645_(_aa_, _6d_); // builds a "second pass" metadata tree for encoding. necessary since string arrays etc. final buffer size is dependent on actual values used
const _ae_ = encode(false, _56_, _6d_); // performs the actual encoding, creates the final buffer immediately since second pass cause size to be known. only the final buffer is worked on
console.log(bufferToHex(_ae_));
// b1e56dfc0000000000000000000000000000000000000000000000000000000123456789

// sample output for us to decode for first overload
const _f4_ = Uint8Array.fromHex("0x0000000000000000000000000000000000000000000000000000000123456789".slice(2)).buffer;
const _dd_ = abiJson[0];
const _3e_ = _655c97_(_dd_, "outputs");
console.log(decode(_f4_, _3e_));
// { value: 4886718345n }

// sample output for us to decode for second overload
const _4d_ = Uint8Array.fromHex("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b68656c6c6f20776f726c64000000000000000000000000000000000000000000".slice(2)).buffer;
const _54_ = abiJson[1];
const _1c_ = _655c97_(_54_, "outputs");
console.log(decode(_4d_, _1c_));
// { text: "hello world" }


// using compiled modules from c880f7 would look like below
// where 0b1577 is the contract name
// and df639c is the overloaded function name
// type signature will look like `_df639c_(includeSelector: boolean, overload: 0, a: bigint): ArrayBuffer (+1 overload)`

console.log(bufferToHex(_0b1577_.encode._df639c_(true, 0, 0x123456789n)));
// b1e56dfc0000000000000000000000000000000000000000000000000000000123456789

console.log(bufferToHex(_0b1577_.encode._df639c_(false, 0, 0x123456789n)));
// 0000000000000000000000000000000000000000000000000000000123456789

console.log(bufferToHex(_0b1577_.encode._df639c_(true, 1, "hello world")));
// cb7f477c0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b68656c6c6f20776f726c64000000000000000000000000000000000000000000

console.log(bufferToHex(_0b1577_.encode._df639c_(false, 1, "hello world")));
// 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b68656c6c6f20776f726c64000000000000000000000000000000000000000000

console.log(_0b1577_.decode._df639c_(0, _f4_));
// { value: 4886718345n }

console.log(_0b1577_.decode._df639c_(1, _4d_));
// { text: "hello world" }