Overview of ABIType
mainABIType provides strict TypeScript types for Ethereum ABIs and EIP-712 Typed Data. It allows you to add type inference and autocomplete to your code based on user-provided ABIs without needing a separate type-generation build step (like TypeChain).
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']
>