Skip to content

Types

Types covering the Contract ABI and EIP-712 Typed Data Specifications.

Abi

Type matching the Contract ABI Specification

import { 
type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[]
Abi
} from 'abitype'

AbiConstructor

ABI Constructor type

import { 
type AbiConstructor = { type: 'constructor'; inputs: readonly AbiParameter[]; payable?: boolean | undefined; stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>; }

ABI "constructor" type

AbiConstructor
} from 'abitype'

AbiError

ABI Error type

import { 
type AbiError = { type: 'error'; inputs: readonly AbiParameter[]; name: string; }

ABI "error" type

AbiError
} from 'abitype'

AbiEvent

ABI Event type

import { 
type AbiEvent = { type: 'event'; anonymous?: boolean | undefined; inputs: readonly AbiEventParameter[]; name: string; }

ABI "event" type

AbiEvent
} from 'abitype'

AbiFallback

ABI Fallback type

import { 
type AbiFallback = { type: 'fallback'; inputs?: readonly [] | undefined; payable?: boolean | undefined; stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>; }

ABI "fallback" type

AbiFallback
} from 'abitype'

AbiFunction

ABI Function type

import { 
type AbiFunction = { type: 'function'; constant?: boolean | undefined; gas?: number | undefined; inputs: readonly AbiParameter[]; name: string; outputs: readonly AbiParameter[]; payable?: boolean | undefined; stateMutability: AbiStateMutability; }

ABI "function" type

AbiFunction
} from 'abitype'

AbiInternalType

Representation used by Solidity compiler (e.g. 'string', 'int256', 'struct Foo')

import { 
type AbiInternalType = string
AbiInternalType
} from 'abitype'

AbiItemType

"type" name for Abi items (e.g. 'type': 'function' for AbiFunction)

import { 
type AbiInternalType = string
AbiInternalType
} from 'abitype'

AbiParameter

inputs and ouputs item for ABI functions, errors, and constructors

import { 
type AbiParameter = { type: ResolvedAbiType; name?: string | undefined; internalType?: AbiInternalType | undefined; } | { type: "tuple" | `tuple[${string}]`; name?: string | undefined; internalType?: AbiInternalType | undefined; components: readonly AbiParameter[]; }
AbiParameter
} from 'abitype'

AbiEventParameter

inputs for ABI events

import { 
type AbiEventParameter = { type: string; name?: string | undefined; internalType?: string | undefined; indexed?: boolean | undefined; } | { type: "tuple" | `tuple[${string}]`; name?: string | undefined; internalType?: string | undefined; components: readonly AbiParameter[]; indexed?: boolean | undefined; }
AbiEventParameter
} from 'abitype'

AbiParameterKind

Kind of ABI parameter: 'inputs' | 'outputs'

import { 
type AbiParameterKind = "inputs" | "outputs"

Kind of AbiParameter

AbiParameterKind
} from 'abitype'

AbiReceive

ABI Receive type

import { 
type AbiReceive = { type: 'receive'; stateMutability: Extract<AbiStateMutability, 'payable'>; }

ABI "receive" type

AbiReceive
} from 'abitype'

AbiStateMutability

ABI Function behavior

import { 
type AbiStateMutability = "pure" | "view" | "nonpayable" | "payable"

State mutability for AbiFunction

AbiStateMutability
} from 'abitype'

AbiType

ABI canonical types

import { 
type AbiType = "string" | "function" | "address" | "bool" | "bytes" | "bytes1" | "bytes2" | "bytes3" | "bytes4" | "bytes5" | "bytes6" | "bytes7" | "bytes8" | "bytes9" | "bytes10" | "bytes11" | ... 88 more ... | SolidityArray
AbiType
} from 'abitype'

Solidity types

Solidity types as template strings

import {
  
type SolidityAddress = "address"
SolidityAddress
,
type SolidityArray = `string[${string}]` | `function[${string}]` | `address[${string}]` | `bool[${string}]` | `bytes[${string}]` | `bytes1[${string}]` | `bytes2[${string}]` | `bytes3[${string}]` | `bytes4[${string}]` | `bytes5[${string}]` | `bytes6[${string}]` | `bytes7[${string}]` | `bytes8[${string}]` | `bytes9[${string}]` | `bytes10[${string}]` | `bytes11[${string}]` | `bytes12[${string}]` | ... 86 more ... | `tuple[${string}]`
SolidityArray
,
type SolidityBool = "bool"
SolidityBool
,
type SolidityBytes = "bytes" | "bytes1" | "bytes2" | "bytes3" | "bytes4" | "bytes5" | "bytes6" | "bytes7" | "bytes8" | "bytes9" | "bytes10" | "bytes11" | "bytes12" | "bytes13" | "bytes14" | "bytes15" | ... 16 more ... | "bytes32"
SolidityBytes
,
type SolidityFunction = "function"
SolidityFunction
,
type SolidityInt = "int" | "int8" | "int16" | "int24" | "int32" | "int40" | "int48" | "int56" | "int64" | "int72" | "int80" | "int88" | "int96" | "int104" | "int112" | "int120" | "int128" | "int136" | ... 47 more ... | "uint256"
SolidityInt
,
type SolidityString = "string"
SolidityString
,
type SolidityTuple = "tuple"
SolidityTuple
,
} from 'abitype'

TypedData

EIP-712 Typed Data Specification

import { 
type TypedData = { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `bool[${string}]`]: undefined; [x: `bytes[${string}]`]: undefined; [x: `bytes1[${string}]`]: undefined; [x: `bytes2[${string}]`]: undefined; [x: `bytes3[${string}]`]: undefined; [x: `bytes4[${string}]`]: undefined; [x: `bytes5[${string}]`]: undefined; [x: `bytes6[${string}]`]: undefined; [x: `bytes7[${string}]`]: undefined; [x: `bytes8[${string}]`]: undefined; [x: `bytes9[${string}]`]: undefined; [x: `bytes10[${string}]`]: undefined; [x: `bytes11[${string}]`]: undefined; [x: `bytes12[${string}]`]: undefined; [x: `bytes13[${string}]`]: undefined; [x: `bytes14[${string}]`]: undefined; [x: `bytes15[${string}]`]: undefined; [x: `bytes16[${string}]`]: undefined; [x: `bytes17[${string}]`]: undefined; [x: `bytes18[${string}]`]: undefined; [x: `bytes19[${string}]`]: undefined; [x: `bytes20[${string}]`]: undefined; [x: `bytes21[${string}]`]: undefined; [x: `bytes22[${string}]`]: undefined; [x: `bytes23[${string}]`]: undefined; [x: `bytes24[${string}]`]: undefined; [x: `bytes25[${string}]`]: undefined; [x: `bytes26[${string}]`]: undefined; [x: `bytes27[${string}]`]: undefined; [x: `bytes28[${string}]`]: undefined; [x: `bytes29[${string}]`]: undefined; [x: `bytes30[${string}]`]: undefined; [x: `bytes31[${string}]`]: undefined; [x: `bytes32[${string}]`]: undefined; [x: `int[${ ...

EIP-712 Typed Data Specification

TypedData
} from 'abitype'

TypedDataDomain

EIP-712 Domain

import { 
type TypedDataDomain = { chainId?: number | undefined; name?: string | undefined; salt?: ResolvedRegister['BytesType']['outputs'] | undefined; verifyingContract?: Address | undefined; version?: string | undefined; }
TypedDataDomain
} from 'abitype'

TypedDataParameter

Entry in TypedData type items

import { 
type TypedDataParameter = { name: string; type: TypedDataType | keyof TypedData | `${keyof TypedData}[${string | ''}]`; }
TypedDataParameter
} from 'abitype'

TypedDataType

Subset of AbiType that excludes tuple and function

import { 
type TypedDataType = "string" | "address" | "bool" | "bytes" | "bytes1" | "bytes2" | "bytes3" | "bytes4" | "bytes5" | "bytes6" | "bytes7" | "bytes8" | "bytes9" | "bytes10" | "bytes11" | "bytes12" | ... 186 more ... | `uint256[${string}]`
TypedDataType
} from 'abitype'