Skip to content

Zod

ABIType exports the core types as Zod schemas from the 'abitype/zod' entrypoint.

Install

Install the Zod peer dependency:

pnpm add zod

Usage

Import and use schemas:

import { Abi } from 'abitype/zod'
 
const result = await fetch(
  'https://api.etherscan.io/api?module=contract&action=getabi&address=0x…'
)
const abi = Abi.parse(result)
## Errors were thrown in the sample, but not included in an errors tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 20 - Cannot find module 'abitype/zod' or its corresponding type declarations.

Schemas

import {
  Abi,
  AbiConstructor,
  AbiEvent,
  AbiEventParameter,
  AbiError,
  AbiFallback,
  AbiFunction,
  AbiParameter,
  Address,
  AbiReceive,
  AbiStateMutability,
  SolidityAddress,
  SolidityArray,
  SolidityArrayWithoutTuple,
  SolidityArrayWithTuple,
  SolidityBool,
  SolidityBytes,
  SolidityFunction,
  SolidityInt,
  SolidityString,
  SolidityTuple,
  TypedData,
  TypedDataDomain,
  TypedDataParameter,
  TypedDataType,
} from 'abitype/zod'
## Errors were thrown in the sample, but not included in an errors tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 444 - Cannot find module 'abitype/zod' or its corresponding type declarations.