# @blueshift-gg/quasar-svm 中文文档

规范地址：https://npmcn.com/package/%40blueshift-gg/quasar-svm/

版本：0\.1\.12
npm 元数据更新时间：2026-03-24T02:57:02.723Z
中文译文更新时间：2026-11-09T20:12:57.693Z
软件包许可：未声明

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40blueshift-gg/quasar-svm
原文对照：https://npmcn.com/package/%40blueshift-gg/quasar-svm/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.7 MB，58 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.13\.0
- 运行依赖：9 个
- peer 依赖：@solana/web3\.js git:blueshift-gg/solana-web3\.js\#v2
- 首次发布：2026-03-12T07:06:24.518Z
- 最新版本发布：2026-03-24T02:57:02.600Z
- 近 30 天下载量：1757（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：13（近 12 个月 13 个）

## 中文简介

类星体- svm 的节点绑定( Solana SVM 执行引擎)

## 安装

```sh
npm install @blueshift-gg/quasar-svm
```

也可以使用：`pnpm add @blueshift-gg/quasar-svm`、`yarn add @blueshift-gg/quasar-svm`、`bun add @blueshift-gg/quasar-svm`

## README

# `quasar-svm`

用于 Rust, Node.js, 和 Python 的正在处理中的索拉纳执行.

## 概览

QuasarSVM是一款轻量级的索拉纳虚拟机,在没有RPC连接或验证器的情况下在当地执行交易. 提供程序ELF,账户状态,以及指令——获取返回日志,计算单位,返回数据,字节级账户diffs,以及由此产生的账户.

`Account` 是所有层次的通用账户类型.

```toml
[dependencies]
quasar-svm = "0.1"
```

```bash
npm install @blueshift-gg/quasar-svm
```

```bash
pip install quasar-svm
```

## 快速启动

### 锈

```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);
```

### 类型脚本 (web3.js)

```ts
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
```

### 类型脚本( kit)

```ts
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
```

> **类型脚本 :** 原生记忆由GC自动释放. 在紧环中进行决定性清理,使用 `using vm = new QuasarSvm()` 或打电话 `vm.free()`。 。 。 .
> 
> **Python : (中文(简体) )** 使用上下文管理器( E)`with QuasarSvm() as svm:`)用于自动清理.

## 文档

| 层 | 读取 | 说明 |
| --- | --- | --- |
| **锈** | [svm/README.md (英语)](https://npmcn.com/package/%40blueshift-gg/quasar-svm/svm/README.md) | 核心 SVM 引擎 : `QuasarSvm`, (中文(简体) ), `ExecutionResult`, (中文(简体) ), `Account`,符号助手 |
| **蟒** | [装订/平顶/README.md](https://npmcn.com/package/%40blueshift-gg/quasar-svm/bindings/python/README.md) | 使用 Python API 的 Python API `solders` 类型(`Pubkey`, (中文(简体) ), `Instruction`, (中文(简体) ), `AccountMeta`(中文(简体) ) |
| **网络3.js** | [约束/节点/src/web3.js/README.md](https://npmcn.com/package/%40blueshift-gg/quasar-svm/bindings/node/src/web3.js/README.md) | 使用脚本 API `@solana/web3.js` 类型(`PublicKey`, (中文(简体) ), `KeyedAccountInfo`(中文(简体) ) |
| **工具包** | [约束/节点/src/kit/README.md](https://npmcn.com/package/%40blueshift-gg/quasar-svm/bindings/node/src/kit/README.md) | 使用脚本 API `@solana/kit` 类型(`Address`, (中文(简体) ), `Account<T>`(中文(简体) ) |

## 出口

| 导入路径 | 地址类型 | 账户类型 | 说明 |
| --- | --- | --- | --- |
| `quasar_svm` | `solders.Pubkey` | `KeyedAccount` | 使用 Python API 的 Python API `solders` |
| `@blueshift-gg/quasar-svm/web3.js` | `PublicKey` | `KeyedAccount` | `@solana/web3.js` API 密码 |
| `@blueshift-gg/quasar-svm/kit` | `Address` | `Account` | `@solana/kit` API 密码 |
| `@blueshift-gg/quasar-svm/ffi` | —— 说 | —— 说 | 低级本地装订 |

所有API都为每种语言暴露出具有平庸类型的同一种核心功能. 网络3.js层额外提供 `toKeyedAccountInfo` 编号 : `fromKeyedAccountInfo` 与遗产代码交叉.

## 工作空间

| 克里特语Name | 路径 | 目的 |
| --- | --- | --- |
| `quasar-svm` | `svm/` | 核心执行引擎 - `QuasarSvm`, (中文(简体) ), `ExecutionResult`, (中文(简体) ), `Account`,符号助手 |
| `quasar-svm-ffi` | `ffi/` | C-ABI 语言绑定的包装 |
| Python 绑定 | `bindings/python/` | 使用 Python API 的 Python API `solders` 索拉纳类型 |
| 类型脚本绑定 | `bindings/node/` | `web3.js` 财务报告和审定财务报表 `kit` 本地引擎上的 API 层 |

## 内建程序

系统程序,BPF Loader v2,以及可升级的Lauger v3,都是随时可用的. SPL程序默认被捆绑并加载.

**锈:**

```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();
```

**类型脚本 :**

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

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

## 发展

这个寄存器在TypeScript工具链和包管理中使用了Bun.

```bash
bun install
```

```bash
# Rust
cargo check --workspace
cargo clippy --workspace

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

## 许可证

麻省理工学院

## 常见问题

### @blueshift-gg/quasar-svm 是什么？

类星体- svm 的节点绑定\( Solana SVM 执行引擎\)

### 如何安装 @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 和提交记录判断。

