百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

wasm_solana

> 编程语言
开源

在浏览器中使用 Rust 来绑定 solana 的 WASM。

170 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

在浏览器中使用 Rust 来绑定 solana 的 WASM。

solana development with a rust based wasm client

Description

This repository contains several crates that make it easier to interact with Solana in WebAssembly environments:

Crate Description
memory_wallet A memory based wallet standard implementation primarily used for testing.
test_utils_insta Test utilities for working with insta redactions
test_utils_keypairs Test utilities for working with pre-defined keypairs
test_utils_solana Testing utilities for Solana programs
wasm_client_solana WebAssembly client for interacting with Solana programs

Why?

The roots of Solana development have always been about "eating glass"—building against the odds with grit and determination. Lately, however, the ecosystem has matured. Development has become easier with the introduction of powerful browser libraries, SDKs, and world-class documentation.

This project asks: what if we went back to our roots? It's a return to the ethos of embracing difficulty and pain to build something truly meaningful. This library is for those who know there are easier languages than Rust, but choose to persevere regardless.

The path will not be easy. Hiring may be difficult, error messages may be cryptic, and progress can be painstaking. But you will build with Rust, you will make meaningful progress, and you will love it.

Crate Details

  • memory_wallet: A wallet-standard compliant in-memory wallet, ideal for testing and prototyping. It manages Keypairs directly in memory, allowing for seamless signing of transactions and messages without requiring user interaction.
…
  • test_utils_insta: Provides helper functions for creating redactions in insta snapshot tests. This is useful for redacting dynamic data like signatures or timestamps, ensuring that snapshots remain consistent across test runs.

    rust
    use insta::assert_debug_snapshot;
    use solana_signature::Signature;
    use test_utils_insta::create_insta_redaction;
    
    let signature = Signature::new_unique();
    
    assert_debug_snapshot!("my_snapshot", &signature, {
      "signature" => create_insta_redaction(signature, "SIGNATURE"),
    });
  • test_utils_keypairs: A collection of pre-defined, constant Keypairs for use in testing. This avoids the need to generate new keypairs in every test and provides known addresses for setting up test scenarios.

    rust
    use test_utils_keypairs::{get_admin_keypair, get_wallet_keypair};
    
    let admin_keypair = get_admin_keypair();
    let wallet_pubkey = get_wallet_keypair().pubkey();
    
    println!("Admin pubkey: {}", admin_keypair.pubkey());
    println!("Wallet pubkey: {}", wallet_pubkey);
  • test_utils_solana: A suite of utilities for Solana integration testing. It simplifies the process of setting up a ProgramTest environment, managing test validators, and creating test accounts, streamlining the entire testing workflow.

    rust
    use solana_program_test::ProgramTest;
    use test_utils_solana::ProgramTestExtension;
    
    let mut program_test = ProgramTest::default();
    program_test.add_program("my_program", my_program_id, None);
    
    // Easily add an account with a specific balance
    program_test.add_account_with_lamports(
        some_pubkey,
        1_000_000_000, // 1 SOL
    );
    
    // let (mut banks_client, _, _) = program_test.start().await;
  • wasm_client_solana: A general-purpose WebAssembly client for the Solana RPC API. It allows you to fetch account information, send transactions, and interact with the Solana network directly from the browser or other WASM runtimes.

    rust
    use std::str::FromStr;
    
    use solana_pubkey::Pubkey;
    use wasm_client_solana::SolanaRpcClient;
    use wasm_client_solana::WasmRpcClient;
    
    async fn get_balance() {
        let client = SolanaRpcClient::new("https://api.devnet.solana.com");
        let pubkey = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap();
    
        let balance = client.get_balance(&pubkey).await;
        println!("Balance: {:?}", balance);
    }

Contributing

devenv is used to provide a reproducible development environment for this project. Follow the getting started instructions.

To automatically load the environment you should install direnv and then load the direnv.

bash
direnv allow .

At this point you should see the nix commands available in your terminal. Any changes made to the .envrc file will require you to run the above command again.

The solana tooling (agave-validator, solana-keygen, solana-test-validator) and monochange are provided by nix through the devenv shell, sourced from ifiokjr/nixpkgs. Run the following command to install the remaining rust binaries (nextest, llvm-cov, wasm-bindgen-cli, ...) locally via cargo bin so you don't need to worry about polluting your global namespace or versioning.

bash
install:cargo:bin

Upgrading devenv

bash
nix profile upgrade devenv

Editor Setup

To setup recommended configuration for your favorite editor run the following commands.

bash
setup:vscode # Setup vscode
bash
setup:helix

License

Unlicense, see the LICENSE file.

Issues· 15 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustadapteranchorbrowsersolana

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言