@blueshift-gg/quasar-svm

中文文档
0.1.12发布于 2026/03/24TypeScriptES Module近 30 天下载 1757

Node.js bindings for quasar-svm (Solana SVM execution engine)

原始使用文档
文档目录12 节
  1. Overview
  2. Quick Start
  3. Rust
  4. TypeScript (web3.js)
  5. TypeScript (kit)
  6. Python
  7. Documentation
  8. Exports
  9. Workspace
  10. Built-in Programs
  11. Development
  12. License

quasar-svm

In-process Solana execution for Rust, Node.js, and Python.

Overview

QuasarSVM is a lightweight Solana virtual machine that executes transactions locally without an RPC connection or validator. Provide program ELFs, account state, and instructions — get back logs, compute units, return data, byte-level account diffs, and resulting accounts.

Account is the universal account type across all layers.

[dependencies]
quasar-svm = "0.1"
npm install @blueshift-gg/quasar-svm
pip install quasar-svm

Quick Start

Rust

use quasar_svm::{QuasarSvm, Pubkey, SPL_TOKEN_PROGRAM_ID};
use quasar_svm::token::*;
use spl_token::state::Account as SplTokenAccount;
use solana_program_pack::Pack;

let authority = Pubkey::new_unique();

let mint = create_keyed_mint_account(&Pubkey::new_unique(), &Mint { decimals: 6, supply: 10_000, ..Default::default() });
let alice = create_keyed_associated_token_account(&authority, &mint.address, 5_000);
let bob   = create_keyed_associated_token_account(&Pubkey::new_unique(), &mint.address, 0);

let ix = spl_token::instruction::transfer(
    &SPL_TOKEN_PROGRAM_ID,
    &alice.address,
    &bob.address,
    &authority,
    &[],
    1_000,
).unwrap();

let mut svm = QuasarSvm::new(); // Token program loaded by default

let result = svm.process_instruction(&ix, &[mint, alice, bob]);

result.assert_success();

// Verify by unpacking account data
let bob_account = result.account(&bob.address).unwrap();
let bob_token = SplTokenAccount::unpack(&bob_account.data).unwrap();
assert_eq!(bob_token.amount, 1_000);

TypeScript (web3.js)

import { QuasarSvm, createKeyedMintAccount, createKeyedAssociatedTokenAccount } from "@blueshift-gg/quasar-svm/web3.js";
import { Address } from "@solana/web3.js";
import { getTransferInstruction } from "@solana/spl-token";
import { getTokenDecoder } from "@solana-program/token";

const vm = new QuasarSvm(); // Token program loaded by default

const authority = new Address("11111111111111111111111111111112"); // Example address
const recipient = new Address("11111111111111111111111111111113");

const mint = createKeyedMintAccount(new Address("TokenMint111111111111111111111111111"), { decimals: 6, supply: 10_000n });
const alice = createKeyedAssociatedTokenAccount(authority, mint.accountId, 5_000n);
const bob = createKeyedAssociatedTokenAccount(recipient, mint.accountId, 0n);

const ix = getTransferInstruction({
  source: alice.accountId,
  destination: bob.accountId,
  owner: authority,
  amount: 1_000n,
});

const result = vm.processInstruction(ix, [mint, alice, bob]);

result.assertSuccess();
console.log(result.account(bob.accountId, getTokenDecoder())?.amount); // 1000n

TypeScript (kit)

import { QuasarSvm, createKeyedMintAccount, createKeyedAssociatedTokenAccount } from "@blueshift-gg/quasar-svm/kit";
import { address } from "@solana/addresses";
import { getTransferInstruction, getTokenDecoder } from "@solana-program/token";

const vm = new QuasarSvm(); // Token program loaded by default

const authority = address("11111111111111111111111111111112"); // Example address
const recipient = address("11111111111111111111111111111113");

const mint = createKeyedMintAccount(address("TokenMint111111111111111111111111111"), { decimals: 6, supply: 10_000n });
const alice = await createKeyedAssociatedTokenAccount(authority, mint.address, 5_000n);
const bob = await createKeyedAssociatedTokenAccount(recipient, mint.address, 0n);

const ix = getTransferInstruction({
  source: alice.address,
  destination: bob.address,
  owner: authority,
  amount: 1_000n,
});

const result = vm.processInstruction(ix, [mint, alice, bob]);

result.assertSuccess();
console.log(result.account(bob.address, getTokenDecoder())?.amount); // 1000n

Python

from quasar_svm import QuasarSvm, create_keyed_mint_account, create_keyed_associated_token_account
from solders.pubkey import Pubkey
from spl.token.instructions import transfer, TransferParams

# Token program loaded by default
with QuasarSvm() as svm:
    authority = Pubkey.new_unique()
    recipient = Pubkey.new_unique()

    # Create mint and token accounts
    mint = create_keyed_mint_account(
        Pubkey.new_unique(),
        mint_authority=authority,
        decimals=6,
        supply=10_000,
    )
    alice = create_keyed_associated_token_account(authority, mint.address, 5_000)
    bob = create_keyed_associated_token_account(recipient, mint.address, 0)

    # Transfer tokens
    ix = transfer(
        TransferParams(
            program_id=mint.owner,
            source=alice.address,
            dest=bob.address,
            owner=authority,
            amount=1_000,
        )
    )

    result = svm.process_instruction(ix, [mint, alice, bob])
    result.assert_success()

    # Verify transfer
    bob_account = result.account(bob.address)
    print(f"Bob's balance: {bob_account.data[64:72]}")  # Token amount at offset 64

TypeScript: Native memory is freed automatically by the GC. For deterministic cleanup in tight loops, use using vm = new QuasarSvm() or call vm.free().

Python: Use context manager (with QuasarSvm() as svm:) for automatic cleanup.

Documentation

LayerREADMEDescription
Rustsvm/README.mdCore SVM engine: QuasarSvm, ExecutionResult, Account, token helpers
Pythonbindings/python/README.mdPython API using solders types (Pubkey, Instruction, AccountMeta)
web3.jsbindings/node/src/web3.js/README.mdTypeScript API using @solana/web3.js types (PublicKey, KeyedAccountInfo)
kitbindings/node/src/kit/README.mdTypeScript API using @solana/kit types (Address, Account<T>)

Exports

Import PathAddress TypeAccount TypeDescription
quasar_svmsolders.PubkeyKeyedAccountPython API using solders
@blueshift-gg/quasar-svm/web3.jsPublicKeyKeyedAccount@solana/web3.js API
@blueshift-gg/quasar-svm/kitAddressAccount@solana/kit API
@blueshift-gg/quasar-svm/ffi——Low-level native bindings

All APIs expose the same core functionality with idiomatic types for each language. The web3.js layer additionally provides toKeyedAccountInfo / fromKeyedAccountInfo for interop with legacy code.

Workspace

CratePathPurpose
quasar-svmsvm/Core execution engine — QuasarSvm, ExecutionResult, Account, token helpers
quasar-svm-ffiffi/C-ABI wrapper for language bindings
Python bindingsbindings/python/Python API using solders for Solana types
TypeScript bindingsbindings/node/web3.js and kit API layers over the native engine

Built-in Programs

The system program, BPF Loader v2, and Upgradeable Loader v3 are always available. SPL programs are bundled and loaded by default.

Rust:

// All SPL programs loaded by default
let svm = QuasarSvm::new();

// Or customize via config
use quasar_svm::QuasarSvmConfig;
let svm = QuasarSvm::new_with_config(QuasarSvmConfig {
    token: true,
    token_2022: false,
    associated_token: true,
});

// Or use builder methods
QuasarSvm::new()
    .with_token_program()
    .with_token_2022_program()
    .with_associated_token_program();

TypeScript:

// All SPL programs loaded by default
const vm = new QuasarSvm();

// Or customize via config
const vm = new QuasarSvm({
  token: true,
  token2022: false,
  associatedToken: true,
});

Development

This repository uses Bun for the TypeScript toolchain and package management.

bun install
# Rust
cargo check --workspace
cargo clippy --workspace

# TypeScript
bun run build
bun run build:native
bun run test

License

MIT

版本与发布记录

@blueshift-gg/quasar-svm 共发布 13 个版本,首次发布于 2026/03/12;过去 12 个月发布了 13 个版本。

版本发布日期距今
0.1.12latest2026/03/247 个月前
0.1.112026/03/247 个月前
0.1.102026/03/247 个月前
0.1.92026/03/247 个月前
0.1.82026/03/247 个月前
0.1.72026/03/217 个月前

关于 @blueshift-gg/quasar-svm 的常见问题

@blueshift-gg/quasar-svm 是什么?

Node.js bindings for quasar-svm (Solana SVM execution engine)

如何安装 @blueshift-gg/quasar-svm?

在项目目录运行 npm install @blueshift-gg/quasar-svm,或使用 pnpm add / yarn add / bun add。

@blueshift-gg/quasar-svm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blueshift-gg/quasar-svm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blueshift-gg/quasar-svm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blueshift-gg/quasar-svm 可以商用吗?

@blueshift-gg/quasar-svm 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@blueshift-gg/quasar-svm 的下载量有多少?

根据 npm 官方下载统计,@blueshift-gg/quasar-svm 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,757 次,日均约 59 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blueshift-gg/quasar-svm 还在维护吗?

最新版本 0.1.12 发布于 2026/03/24(7 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/03/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。