Socket
Socket
Sign inDemoInstall

abitype

Package Overview
Dependencies
2
Maintainers
2
Versions
173
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    abitype

Strict TypeScript types for Ethereum ABIs


Version published
Weekly downloads
670K
increased by8.14%
Maintainers
2
Install size
463 kB
Created
Weekly downloads
 

Readme

Source

ABIType logo


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 { ExtractAbiFunctions } from 'abitype'
import { erc20Abi } from 'abitype/test'

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).

Install

npm i abitype
yarn add abitype
pnpm add abitype

Documentation

For full documentation, visit abitype.dev.

Community

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

Sponsor

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

Contributing

If you're interested in contributing to ABIType, please read our contributing docs before submitting a pull request.

Keywords

FAQs

Last updated on 10 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc