Generate Parsers with Codama

How-to generate Vixen parser with Codama

This guide walks you through generating a Vixen Parser using Codama, a tool for rendering Rust SDKs and parser implementations from IDLs.

Vixen is a framework for building real-time program data pipelines in Rust. This guide helps you scaffold a parser that can be used in the Vixen runtime to decode and process Solana program data.

Prerequisites

  1. An idl.json file: Either Anchor-generated or custom.

  2. Install pnpm: Or use npm/yarn if preferred.

  3. Initialize a JavaScript Project:

    pnpm init

Installation

Install the required Codama packages:

pnpm install @codama/renderers-vixen-parser

Also, install dependencies for the parser generation script:

pnpm install \
  @codama/nodes \
  @codama/nodes-from-anchor \
  @codama/renderers-core \
  @codama/visitors-core

Setup

Create a Parser Generation Script

Create a new file, codama.cjs:

Tip: The projectName is used for the Cargo crate name of the generated parser.

Run the Code Generation Script

Your folder structure should look like:

Build and Verify

If successful, you now have a working parser for Solana account data using Yellowstone Vixen.

Completion

Congratulations! You now have a custom Vixen parser ready for integration into a Vixen pipeline.

Last updated

Was this helpful?