Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/blueshift-gg/quasar/llms.txt

Use this file to discover all available pages before exploring further.

Quasar uses an Interface Definition Language (IDL) as the canonical description of your program’s public surface: its instructions, account types, error codes, and events. The quasar idl command extracts this description from your Rust source code, and quasar client turns it into ready-to-use client code in TypeScript, Python, Go, or C. Both commands are also run automatically during quasar build, so generated clients stay in sync with your program on every compile.

quasar idl

quasar idl PATH generates the IDL JSON for a program crate and writes it to target/idl/<name>.json. It also generates a Rust client crate in target/client/rust/. The PATH argument is the path to the program crate directory — typically . when running from the project root.
quasar idl .
quasar idl programs/my-program

How IDL Generation Works

Quasar extracts the IDL by compiling the program crate with the idl-build Cargo feature enabled and running a special __quasar_emit_idl test that prints the IDL as JSON to stdout. The Quasar framework macro infrastructure captures instruction discriminators, account field names and types, error variants, and event definitions at compile time, so the IDL always reflects the actual compiled program — not a hand-written description. Your Cargo.toml must include the idl-build feature for this to work:
[features]
idl-build = ["quasar-lang/idl-build"]
This feature is included by default in all projects scaffolded with quasar init.

Output

target/
└── idl/
    └── my_program.json
The IDL JSON file is also used by quasar lint to track your program’s public surface in quasar.lock.json.

IDL JSON Structure

The IDL JSON describes every public-facing element of your program. Here is an example structure:
{
  "name": "my_program",
  "version": "0.1.0",
  "address": "4rEGsVnJb3...",
  "instructions": [
    {
      "name": "initialize",
      "discriminator": 0,
      "accounts": [
        { "name": "payer", "signer": true, "writable": false },
        { "name": "system_program", "signer": false, "writable": false }
      ],
      "args": []
    }
  ],
  "accounts": [
    {
      "name": "MyAccount",
      "discriminator": 1,
      "fields": [
        { "name": "authority", "type": "address" },
        { "name": "value", "type": "u64" }
      ]
    }
  ],
  "types": [],
  "errors": [
    { "code": 0, "name": "Unauthorized", "msg": "Unauthorized" }
  ],
  "events": []
}
FieldDescription
nameProgram crate name (snake_case)
versionVersion from Cargo.toml
addressOn-chain program ID from declare_id!()
instructions[]All #[instruction] handlers with discriminators, accounts, and args
accounts[]All #[account] structs with discriminators and fields
types[]Shared types referenced by instructions or accounts
errors[]All #[error_code] variants
events[]All #[event] structs

quasar client

quasar client IDL [--lang ...] generates client code from an IDL JSON file. By default it generates clients for all supported languages; use --lang to restrict to specific ones.
quasar client target/idl/my_program.json
quasar client target/idl/my_program.json --lang typescript
quasar client target/idl/my_program.json --lang typescript,golang
quasar client target/idl/my_program.json --lang python

Flags

FlagDescription
IDLPath to the IDL JSON file (e.g. target/idl/my_program.json)
--lang LANGComma-separated list of languages to generate. Options: typescript, python, golang, c. Default: all.
Language aliases are accepted: tstypescript, pypython, gogolang.

Output Paths

Client code is written to the path configured in Quasar.toml under clients.path (default: target/client/):
target/client/
├── typescript/
│   └── my_program/
│       ├── web3.ts
│       ├── kit.ts
│       └── package.json
├── python/
│   └── my_program/
│       ├── client.py
│       └── __init__.py
├── golang/
│   └── my_program/
│       ├── client.go
│       └── go.mod
└── c/
    └── my_program/
        └── client.h

Generated Client Code

The TypeScript client includes two variants: kit.ts for @solana/kit (the modern Solana TypeScript SDK) and web3.ts for @solana/web3.js. Both provide strongly typed instruction builders and account decoders.Example usage with @solana/kit:
import { address, createSolanaRpc } from "@solana/kit";
import { createInitializeInstruction } from "./target/client/typescript/my_program/kit";

const rpc = createSolanaRpc("https://api.devnet.solana.com");
const programAddress = address("4rEGsVnJb3...");

const ix = createInitializeInstruction({
  programAddress,
  accounts: {
    payer: payerAddress,
    systemProgram: address("11111111111111111111111111111111"),
  },
});
The generated package.json in the client directory declares the correct peer dependencies so the client can be published as a standalone npm package.

Typical IDL & Client Workflow

1

Write and build your program

quasar build
quasar build automatically generates the IDL and all configured client languages. You only need to run quasar idl or quasar client manually when you want to target a specific crate path or language outside of the normal build flow.
2

Inspect the generated IDL

cat target/idl/my_program.json
Verify that all your instructions, accounts, and errors appear with the correct discriminators and field types.
3

Generate clients from a saved IDL

If you have an IDL JSON from a deployed program and want to regenerate clients without a local source build:
quasar client target/idl/my_program.json --lang typescript,python
4

Commit the IDL

The IDL JSON is the public contract for your program. Commit target/idl/<name>.json to source control so that client developers can regenerate their own clients without having to build the Rust crate.
Client code is regenerated on every quasar build. If you change an instruction signature, account layout, or error variant, the generated clients are updated automatically. Run quasar lint to see a diff of what changed relative to quasar.lock.json.

Build docs developers (and LLMs) love