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