Documentation
Utilities
mergeAbis

mergeAbis

Combines many ABIs into one. Removes duplicate items if necessary.

Usage

index.ts
import { mergeAbis } from "@ponder/utils";
import { erc20Abi, erc4626Abi } from "viem";
 
const tokenAbi = mergeAbis([erc20Abi, erc4626Abi]);

Usage in Ponder

Use mergeAbis to preserve type safety when combining multiple ABIs for a single contract. This is especially useful for proxy contracts that have had several different implementation ABIs.

For convenience, @ponder/core re-exports mergeAbis from @ponder/utils.

ponder.config.ts
import { createConfig, mergeAbis } from "@ponder/core";
import { http } from "viem";
 
import { ERC1967ProxyAbi } from "./abis/ERC1967Proxy";
import { NameRegistryAbi } from "./abis/NameRegistry";
import { NameRegistry2Abi } from "./abis/NameRegistry2";
 
export default createConfig({
  networks: {
    goerli: { chainId: 5, transport: http(process.env.PONDER_RPC_URL_5) },
  },
  contracts: {
    FarcasterNameRegistry: {
      abi: mergeAbis([ERC1967ProxyAbi, NameRegistryAbi, NameRegistry2Abi]),
      network: "goerli",
      address: "0xe3Be01D99bAa8dB9905b33a3cA391238234B79D1",
      startBlock: 7648795,
    },
  },
});

Parameters

ABIs

  • Type: Abi[] (required)

A list of ABIs to merge.

Returns

  • Type: Abi

A new ABI including all items from the input list, with duplicates removed.