Skip to main content
Version: Current

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 erc20.json

    If you use this option, you can also place your JSON ABIs to the abi folder and run

    sqd typegen

    Script is available in all EVM templates.

  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.