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:
-
as a plain JSON file(s):
To include all files in
./abiand add an interface for the Multicall contract, runYou can get JSON ABIs for explorer (Etherscan, Bscscan etc) verified contract by visiting the contract page, going to the “Contract” tab and scrolling down to the “Contract ABI” section. Do not use the “Export ABI” function! Copy the contents to the clipboard and paste them to a new JSON file. -
(requires an Etherscan API key) as a contract address. One can pass multiple addresses at once.
Please check if your contract is a proxy when using this method. If it is, consult this page for guidance.
-
as an arbitrary URL:
basename of the ABI as the root name for the generated files. You can change the basename of generated files using the fragment (#) suffix.
output-dir | output directory for generated definitions |
abi | A contract address, an URL or a local path to the ABI file. Accepts multiple contracts. |
--multicall | generate 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, https://api.etherscan.io/ |
--clean | delete output directory before the run |
-h, --help | display help for command |
Usage
The generated utility modules have three intended uses:-
Constants: EVM log topic0 values and sighashes for transactions. Example:
- Decoding of EVM logs and transactions
- Direct chain state queries, including queries to multicall.
typegen.json config file is best illustrated with an example:
specVersions field is either
- a metadata service endpoint URL, like
In the rare cases when the typegen needs a types bundle, supply it alongside metadata:
TypeScript wrappers
Wrappers generated by the typegen command can be found in the specifiedoutDir (src/types by convention). Assuming that this folder is imported as types (e.g. with import * as types from './types'), you’ll be able to find the wrappers at:
- for events: “
types.events.$\{palletName\}.$\{eventName\}” - for calls: “
types.calls.$\{palletName\}.$\{callName\}” - for storage items: “
types.storage.$\{palletName\}.$\{storageItemName\}” - for constants: “
types.constants.$\{palletName\}.$\{constantName\}”
Balances.ExistentialDeposit becomes types.events.balances.existentialDeposit and the call Balances.set_balance becomes types.calls.setBalance.
Usage
-
Item name constants (e.g.
events.balances.transfer.name). - Runtime versioning-aware decoding.
- Chain storage queries
-
Runtime constants:
Balances.ExistentialDeposit (runtime version V1020): "$\{c\})”
}
}
})
squid-ink-typegen to generate facade classes for decoding ink! smart contract data from JSON ABI metadata.
Usage:
@subsquid/ink-abi under the hood

