Skip to main content
Home

Built and signed on GitHub Actions

Strict TypeScript types for Ethereum ABIs

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
52%
Published
6 months ago (1.0.8)

ABIType logo

Strict TypeScript types for Ethereum ABIs


Strict TypeScript types for Ethereum ABIs. ABIType provides utilities and type definitions for ABI properties and values, covering the Contract ABI Specification, as well as EIP-712 Typed Data.

import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction, ExtractAbiFunctionNames } from 'abitype'
import { erc20Abi } from 'abitype/abis'

type FunctionNames = ExtractAbiFunctionNames<typeof erc20Abi, 'view'>
//   ^? type FunctionNames = "symbol" | "name" | "allowance" | "balanceOf" | "decimals" | "totalSupply"

type TransferInputTypes = AbiParametersToPrimitiveTypes<
  // ^? type TransferInputTypes = readonly [`0x${string}`, bigint]
  ExtractAbiFunction<typeof erc20Abi, 'transfer'>['inputs']
>

Works great for adding blazing fast autocomplete and type checking to functions, variables, or your own types. No need to generate types with third-party tools – just use your ABI and let TypeScript do the rest!

TL;DR

ABIType might be a good option for your project if:

  • You want to typecheck your ABIs or EIP-712 Typed Data.
  • You want to add type inference and autocomplete to your library based on user-provided ABIs or EIP-712 Typed Data, like Wagmi and Viem.
  • You need to convert ABI types (e.g. 'string') to TypeScript types (e.g. string) or other type transformations.
  • You need to validate ABIs at runtime (e.g. after fetching from external resource).
  • You don’t want to set up a build process to generate types (e.g. TypeChain).

Documentation

For documentation and guides, visit abitype.dev.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss ABIType on GitHub

For casual chit-chat with others using the library:

Join the Wevm Discord

Sponsors

If you find ABIType useful or use it for work, please consider supporting development on GitHub Sponsors or sending crypto to wevm.eth. Thank you πŸ™

Contributing

Contributions to ABIType are greatly appreciated! If you're interested in contributing to ABIType, please read the Contributing Guide before submitting a pull request.



Powered by Vercel
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";
or

Import directly with a jsr specifier

import * as abitype from "jsr:@wevm/abitype";

Add Package

pnpm i jsr:@wevm/abitype
or (using pnpm 10.8 or older)
pnpm dlx jsr add @wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";

Add Package

yarn add jsr:@wevm/abitype
or (using Yarn 4.8 or older)
yarn dlx jsr add @wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";

Add Package

vlt install jsr:@wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";

Add Package

npx jsr add @wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";

Add Package

bunx jsr add @wevm/abitype

Import symbol

import * as abitype from "@wevm/abitype";