ABIs and Typescript types of your favorite smartcontracts.
I was a quite frustrated to always include a abi and type generation in each of my projects. Even for the most fundamental contracts like ERC721 and ERC20. It's just such bloat to setup even for a quick proof of concept project. Therefore I created this package to provide easy access to ABIs and types to popular smartcontract libraries.
The first contracts to include are from solmate, which obviously also inspired the projects name.
This repository is setup as a monorepo using nx and will probably contain more ABIs and types in the future. Feel free to open a pull request with your favorite smartcontract libraries.
Currently included is:
npm install @abimate/solmate
npm install @abimate/openzeppelin
Here is an example usage of the ABI and ERC721 contract type.
import { balanceOf } from '@abimate/solmate/ERC20';
import { getContract } from '@wagmi/core';
const ERC20 = [balanceOf];
const token = getContract({
address: '0x23581767a106ae21c074b2276D25e5C3e136a68b',
abi: ERC20,
});
const balance = await token.callStatic.balanceOf('0x23581767a106ae21c074b2276D25e5C3e136a68b');
import { Contract } from 'ethers';
import ABI from '@abimate/solmate/ERC20';
import { ERC20 } from '@abimate/solmate/types/ERC20';
const token = new Contract(
'0x23581767a106ae21c074b2276D25e5C3e136a68b',
ABI
) as ERC20;
token.functions.balanceOf('0x23581767a106ae21c074b2276D25e5C3e136a68b');
npm install @abimate/core
abimate [output_path] [input_files]
Requirements:
nx
- https://nx.dev/foundry
- https://getfoundry.sh/
Commands to run a build:
git clone git@github.com:peetzweg/abimate.git
cd abimate
git submodule update --init --recursive
npm install
nx build solmate
Generate new package:
nx generate @nrwl/js:library --name=PACKAGE_NAME --buildable
Add contract code via submodule:
git submodule add <remote_url> packages/PACKAGE_NAME/lib
Code in this repository is directly referencing:
Licensing of the original source code applies. See individual licenses in /packages/{PACKAGE_NAME}/LICENSE
.