Skip to content

ABITypeABIType

VersionVersionDownloads per monthDownloads per monthMIT LicenseMIT LicenseGitHub Repo starsGitHub Repo starsBest of JSBest of JS

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<abiParameters extends readonly AbiParameter[], abiParameterKind extends AbiParameterKind = AbiParameterKind> = { [key in keyof { [key in keyof abiParameters]: AbiParameterToPrimitiveType<abiParameters[key], abiParameterKind>; }]: { [key in keyof abiParameters]: AbiParameterToPrimitiveType<abiParameters[key], abiParameterKind>; }[key]; }

Converts array of AbiParameter to corresponding TypeScript primitive types.

AbiParametersToPrimitiveTypes
,
type ExtractAbiFunction<abi extends Abi, functionName extends ExtractAbiFunctionNames<abi>, abiStateMutability extends AbiStateMutability = AbiStateMutability> = Extract<abi[number], { type: "function"; stateMutability: abiStateMutability; }> extends { name: functionName; } ? { name: functionName; } & Extract<...> : never

Extracts AbiFunction with name from Abi.

ExtractAbiFunction
} from 'abitype' import {
const erc20Abi: readonly [{ readonly type: "event"; readonly name: "Approval"; readonly inputs: readonly [{ readonly indexed: true; readonly name: "owner"; readonly type: "address"; }, { readonly indexed: true; readonly name: "spender"; readonly type: "address"; }, { readonly indexed: false; readonly name: "value"; readonly type: "uint256"; }]; }, ... 9 more ..., { ...; }]
erc20Abi
} from 'abitype/abis'
type
type TransferInputTypes = readonly [`0x${string}`, bigint]
TransferInputTypes
=
type AbiParametersToPrimitiveTypes<abiParameters extends readonly AbiParameter[], abiParameterKind extends AbiParameterKind = AbiParameterKind> = { [key in keyof { [key in keyof abiParameters]: AbiParameterToPrimitiveType<abiParameters[key], abiParameterKind>; }]: { [key in keyof abiParameters]: AbiParameterToPrimitiveType<abiParameters[key], abiParameterKind>; }[key]; }

Converts array of AbiParameter to corresponding TypeScript primitive types.

AbiParametersToPrimitiveTypes
<
type ExtractAbiFunction<abi extends Abi, functionName extends ExtractAbiFunctionNames<abi>, abiStateMutability extends AbiStateMutability = AbiStateMutability> = Extract<abi[number], { type: "function"; stateMutability: abiStateMutability; }> extends { name: functionName; } ? { name: functionName; } & Extract<...> : never

Extracts AbiFunction with name from Abi.

ExtractAbiFunction
<typeof
const erc20Abi: readonly [{ readonly type: "event"; readonly name: "Approval"; readonly inputs: readonly [{ readonly indexed: true; readonly name: "owner"; readonly type: "address"; }, { readonly indexed: true; readonly name: "spender"; readonly type: "address"; }, { readonly indexed: false; readonly name: "value"; readonly type: "uint256"; }]; }, ... 9 more ..., { ...; }]
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).

Install

Read the Getting Started guide to learn more how to use ABIType.

pnpm add abitype

Sponsor

If you find ABIType useful, please consider supporting development on GitHub Sponsors or sending crypto to wevm.eth. Thank you 🙏

Community

If you have questions or need help, reach out to the community at the ABIType GitHub Discussions.

https://yta.tgdaddy.com https://pfx.cuckootool.com https://yfj.tgapi.one https://eiw.tgdaddy.com https://ojb.ibook77.com https://luq.book79.com https://gka.tgsession.com https://ubk.fatv8.com https://xts.tgapi.one https://lha.tgsession.com Car Dealer Reviews, Dealership Ratings, Cars For Sale | DealerRater イオンモール四條畷公式ホームページ Exeunt Magazine - Exeunt is an online theatre magazine for quality theatre criticism, interviews, essays, long-form writing and, podcasts. Publicidad en LA NUEVA ESPAÑA University of Vechta - Academia.edu Terra - Seu Portal de Notícias, Diversão e Esportes Casa 1 - Casa 1 une acolhida de jovens LGBT+ , centro cultural e clínica de saúde mental gratuita カオスアンテナ けもちゃん The best vintage and classic cars for sale online | Bring a Trailer