Skip to main content
A typegen is a tool for generating utility code for technology-specific operations such as decoding. Solana typegen:
  • decodes instruction and log message data based on the IDL
  • exposes useful constants such as program IDs and instruction discriminators
  • provides functions that simplify selecting data items based on accounts
Install it with
Replace npx squid-solana-typegen with npx @subsquid/solana-typegen if you don’t want to install the package.
The squid-solana-typegen tool generates TypeScript facades for Solana instructions and logs. It takes JSON IDLs as inputs. The IDLs can be specified in three ways:
  1. as a plain JSON file(s):
    If you use this option, you can also place your JSON IDLs to the idl folder and run
  2. load IDL from a Solana node or the SolanaFM registry and generate types:
    Use --solana-rpc-endpoint <url> to choose the RPC endpoint for onchain IDL lookup.
  3. load an IDL from an HTTP(S) URL:
Pass --clean to delete the output directory before generation.

Usage

The generated utility modules have three intended uses:
  1. Constants: Solana instruction discriminators:
  2. Decoding of Solana instructions
  3. Simplifying the account-specific data requests
The generated instruction descriptors also work with getInstructionData() and getInstructionDescriptor() from @subsquid/solana-stream.