Quick start with whatsabi.autoload()
mainThe whatsabi.autoload(address, options) method is the primary entry point for resolving a contract's ABI. It automatically loads bytecode from a provider, extracts selectors, and attempts to resolve signatures and ABIs using available loaders. It works with any provider library like Ethers.js, Viem, or Web3.js.
To use it with Ethers.js:
import { ethers } from "ethers";
import { whatsabi } from "@shazow/whatsabi";
const provider = ethers.getDefaultProvider();
const address = "0x00000000006c3852cbEf3e08E8dF289169EdE581";
const result = await whatsabi.autoload(address, { provider });
console.log(result.abi);To use it with Viem:
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { whatsabi } from "@shazow/whatsabi";
const client = createPublicClient({ chain: mainnet, transport: http() })
const address = "0x...";
const result = await whatsabi.autoload(address, { provider: client });