Skip to main content

Generating utility modules

The squid-evm-typegen(1) tool generates TypeScript facades for EVM transactions, logs and eth_call queries.

The generated facades are assumed to be used by squids indexing EVM data.

The tool takes a JSON ABIs as an input. Those can be specified in three ways:

  1. as a plain JSON file(s):

    npx squid-evm-typegen src/abi abi/erc20.json

    To include all files in ./abi and add an interface for the Multicall contract, run

    npx squid-evm-typegen ./src/abi ./abi/*.json --multicall
  2. as a contract address (to fetch the ABI from Etherscan API). Once can pass multiple addresses at once.

    npx squid-evm-typegen src/abi 0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413

Please check if your contract is a proxy when using this method. If it is, consult this page for guidance.

  1. as an arbitrary URL:

    npx squid-evm-typegen src/abi

In all cases typegen will use basename of the ABI as the root name for the generated files. You can change the basename of generated files using the fragment (#) suffix.

squid-evm-typegen src/abi 0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413#my-contract-name


output-diroutput directory for generated definitions
abiA contract address, an URL or a local path to the ABI file. Accepts multiple contracts.


--multicallgenerate a facade for the MakerDAO multicall contract. May significantly improve the performance of contract state calls by batching RPC requests
--etherscan-api <url>etherscan API to fetch contract ABI by a known address. By default,
--cleandelete output directory before the run
-h, --helpdisplay help for command


The generated utility modules have three intended uses:

  1. Constants: EVM log topic0 values and sighashes for transactions. Example:

    // generated by evm-typegen
    import * as weth from './abi/weth'

    const CONTRACT_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'.toLowerCase()

    const processor = new EvmBatchProcessor()
    address: [CONTRACT_ADDRESS],
    topic0: [,
  2. Decoding of EVM logs and transactions

  3. Direct chain state queries, including queries to multicall.