$ npm install abitype
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!
ABIType might be a good option for your project if:
'string'
) to TypeScript types (e.g. string
) or other type transformations.For documentation and guides, visit abitype.dev.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using the library:
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 ๐
Contributions to ABIType are greatly appreciated! If you're interested in contributing to ABIType, please read the Contributing Guide before submitting a pull request.
© 2010 - cnpmjs.org x YWFE | Home | YWFE