Squid substrate typegen
Reference page of the squid-substrate-typegen command line tool

Installation

The Squid substrate typegen tool is part of Subsquid SDK and is used for generating TypeScript interface classes for Substrate Events and calls.
Note: in the context of this guide, we assume the Development Environment has been already set up and that npm is used, although other options are available.
To install substrate typegen tool, simply run this in a console.
1
npm install @subsquid/substrate-typegen
Copied!
Once installed, check available commands by running
1
npx squid-substrate-typegen --help
Copied!
Which will print out a help.

Options for squid-substrate-typegen command

Argument
Description
Required
-h or --help
display help for command
config
JSON file with options
yes

Config file structure

The config parameter is the path to a JSON file containing configuration directives for how to perform the code generation. It typically has this structure:
1
{
2
"outDir": "src/types",
3
"chainVersions": "kusamaVersions.json",
4
"typesBundle": "kusama",
5
"events": [
6
"balances.Transfer"
7
],
8
"calls": [
9
"timestamp.set"
10
]
11
}
Copied!
This is a brief description of the various fields:
Key
Description
outDir
output directory for generated code
chainVersions
the output file of chain exploration
typesBundle
external type definitions, required for chains having blocks with metadata versions below 14 (see FAQ), similar to polkadot.js typesbundle, but with slightly different structure. It can either be a built-in typesBundle or a path to a typesBundle JSON file.
events
list of Events to generate
calls
list of calls (or Extrinsics) to generate
For a more in-depth explanation of the subject, head over to the dedicated page and for a practical guide, take a look at the dedicated Recipe.