Triton One Docs
WebsiteCustomer Portal
  • Introduction
  • RPC Pool
    • Introduction
    • GeoDNS
    • Abuse prevention
    • Rate Limits
    • Proxying
    • Support FAQs
    • Privacy & Security
  • Chains
    • Solana
      • Streaming
      • BigTable Archive
      • Improved Priority Fees API
        • For RPC Providers
      • Cascade
        • Transaction sending advice
        • Buying Transaction Bandwidth
        • Providing Transaction Bandwidth
      • Web3JS Socket/Connection Issues
      • Deprecated calls Solana 2.0
    • Pythnet
    • SUI
    • Others
  • Digital Assets API
    • Introduction
    • Fungible Assets
    • API Methods
      • Get Asset
      • Get Asset Proof
      • Get Assets By Authority
      • Get Assets By Owner
      • Get Assets By Group
      • Get Assets By Creator
      • Search Assets
      • Get Token Accounts
      • Get Signatures For Asset
      • Get NFT Editions
      • Get Asset Proofs
  • Project Yellowstone
    • Introduction
    • Dragon's Mouth gRPC Subscriptions
    • Old Faithful Historical Archive
      • Old Faithful Public Report
    • Steamboat Custom Indexes
    • Whirligig WebSockets
    • Fumarole Reliable Streams
    • Vixen Data Pipelines
      • Generate Parsers with Codama
  • Shield Transaction Policies
  • Account Management
    • Payments
    • Account management API
      • Introduction
      • Auth & Headers
      • Accounts
      • Address Watch Lists
      • Subscriptions
      • Subscription Types
      • Endpoints
      • Tokens
      • Rate Tiers
  • Trading APIs
    • Introduction
    • Jupiter swap
    • Pyth Hermes
    • Bundle simulation by Jito
  • Validators
    • Introduction
    • Vote account setup
    • Node identity protection
  • Pyth Publishers
    • NGINX proxy
    • Testnet, Devnet and Pythnet
Powered by GitBook
On this page

Was this helpful?

  1. Project Yellowstone
  2. Vixen Data Pipelines

Generate Parsers with Codama

How-to generate Vixen parser with Codama

PreviousVixen Data PipelinesNextShield Transaction Policies

Last updated 1 day ago

Was this helpful?

This guide walks you through generating a Parser using , 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 : 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:

const path = require("node:path");
const { rootNode } = require("@codama/nodes");
const { rootNodeFromAnchor } = require("@codama/nodes-from-anchor");
const { readJson } = require("@codama/renderers-core");
const { visit } = require("@codama/visitors-core");
const { renderVisitor } = require("@codama/renderers-vixen-parser");

const projectName = "example-parser";
const idl = readJson(path.join(__dirname, "idl.json"));
const node = rootNodeFromAnchor(idl);

visit(
    node,
    renderVisitor({
        projectFolder: __dirname,
        projectName,
    }),
);

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

Run the Code Generation Script

node codama.cjs

Your folder structure should look like:

example-parser/
├── proto/
│   └── example_parser.proto
├── src/
│   ├── generated_parser/
│   ├── generated_sdk/
│   └── lib.rs
├── build.rs
├── Cargo.toml
├── codama.cjs
└── idl.json

Build and Verify

cargo build

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.

Vixen
Codama
pnpm