Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wevm/abitype
Strict TypeScript types for Ethereum ABIs
https://github.com/wevm/abitype
abi ethereum static-types type-inference types typescript web3
Last synced: 5 days ago
JSON representation
Strict TypeScript types for Ethereum ABIs
- Host: GitHub
- URL: https://github.com/wevm/abitype
- Owner: wevm
- License: mit
- Created: 2022-08-03T17:19:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T15:45:30.000Z (3 months ago)
- Last Synced: 2024-10-30T06:57:43.375Z (13 days ago)
- Topics: abi, ethereum, static-types, type-inference, types, typescript, web3
- Language: TypeScript
- Homepage: https://abitype.dev
- Size: 1.41 MB
- Stars: 479
- Watchers: 7
- Forks: 44
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Strict TypeScript types for Ethereum ABIs---
Strict TypeScript types for Ethereum ABIs. ABIType provides utilities and type definitions for ABI properties and values, covering the [Contract ABI Specification](https://docs.soliditylang.org/en/latest/abi-spec.html), as well as [EIP-712](https://eips.ethereum.org/EIPS/eip-712) Typed Data.
```ts
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction, ExtractAbiFunctionNames } from 'abitype'
import { erc20Abi } from 'abitype/abis'type FunctionNames = ExtractAbiFunctionNames
// ^? type FunctionNames = "symbol" | "name" | "allowance" | "balanceOf" | "decimals" | "totalSupply"type TransferInputTypes = AbiParametersToPrimitiveTypes<
// ^? type TransferInputTypes = readonly [`0x${string}`, bigint]
ExtractAbiFunction['inputs']
>
```Works great for adding blazing fast [autocomplete](https://twitter.com/awkweb/status/1555678944770367493) and type checking to functions, variables, or your own types. No need to generate types with third-party tools β just use your ABI and let TypeScript do the rest!
## TL;DR
ABIType might be a good option for your project if:
- You want to [typecheck](https://abitype.dev/api/types) your ABIs or EIP-712 Typed Data.
- You want to add type inference and autocomplete to your library based on user-provided ABIs or EIP-712 Typed Data, like [Wagmi](https://wagmi.sh) and [Viem](https://viem.sh).
- You need to [convert ABI types](https://abitype.dev/api/utilities#abiparameterstoprimitivetypes) (e.g. `'string'`) to TypeScript types (e.g. `string`) or other type transformations.
- You need to validate ABIs at [runtime](https://abitype.dev/api/zod) (e.g. after fetching from external resource).
- You donβt want to set up a build process to generate types (e.g. TypeChain).## Documentation
For documentation and guides, visit [abitype.dev](https://abitype.dev).
## Community
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
[Discuss ABIType on GitHub](https://github.com/wevm/abitype/discussions)
For casual chit-chat with others using the library:
[Join the Wevm Discord](https://discord.gg/SghfWBKexF)
## Sponsors
If you find ABIType useful or use it for work, please consider supporting development on [GitHub Sponsors](https://github.com/sponsors/wevm?metadata_campaign=abitype_readme) or sending crypto to `wevm.eth`. Thank you π
## Contributing
Contributions to ABIType are greatly appreciated! If you're interested in contributing to ABIType, please read the [Contributing Guide](https://github.com/wevm/abitype/blob/main/.github/CONTRIBUTING.md) **before submitting a pull request**.