Zod
ABIType exports the core types as Zod schemas from the 'abitype/zod'
entrypoint.
Install
Install the Zod peer dependency:
bash
pnpm add zod
pnpm add zod
bash
bun add zod
bun add zod
bash
npm i zod
npm i zod
bash
yarn add zod
yarn add zod
Usage
Import and use schemas:
ts
tsTry
import {Abi } from 'abitype/zod'constresult = awaitfetch ('https://api.etherscan.io/api?module=contract&action=getabi&address=0x…')constabi =Abi .parse (result )
tsTry
import {Abi } from 'abitype/zod'constresult = awaitfetch ('https://api.etherscan.io/api?module=contract&action=getabi&address=0x…')constabi =Abi .parse (result )
Schemas
ts
tsTry
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'
tsTry
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'