#solana #wasm-client #rpc-client #browser #pubsub #compatible #zstd

wasm_client_solana

A wasm compatible solana rpc and pubsub client

20 releases (6 breaking)

0.7.5 Jan 17, 2025
0.7.3 Dec 21, 2024
0.6.1 Nov 4, 2024

#1283 in Web programming

Download history 90/week @ 2024-10-29 71/week @ 2024-11-05 7/week @ 2024-11-12 12/week @ 2024-11-19 4/week @ 2024-11-26 8/week @ 2024-12-03 458/week @ 2024-12-10 152/week @ 2024-12-17 15/week @ 2024-12-24 15/week @ 2025-01-07 235/week @ 2025-01-14 26/week @ 2025-01-21 378/week @ 2025-02-04 200/week @ 2025-02-11

619 downloads per month
Used in 9 crates

Unlicense

770KB
23K SLoC

wasm_client_solana


A wasm compatible solana rpc and pubsub client.


Crate Docs Status Unlicense codecov

Installation

To install you can use the following command:

cargo add wasm_client_solana

Or directly add the following to your Cargo.toml:

[dependencies]
wasm_client_solana = "0.1" # replace with the latest version

Features

This crate provides the following features:

  • js: Enables the use of the wasm-bindgen crate for the js target. This is useful for using the crate in a browser environment.
  • ssr: Enables the use of the reqwest and tokio crates for the ssr target. This is useful for using the crate in a server or non-browser environment.
  • zstd: Enables the use of the zstd as an encoding format and automatically activates the ssr target.

Usage

The SolanaRpcClient provides a wasm compatible client for the solana rpc and pubsub methods.

use solana_sdk::native_token::sol_to_lamports;
use solana_sdk::pubkey;
use wasm_client_solana::ClientResult;
use wasm_client_solana::SolanaRpcClient;
use wasm_client_solana::DEVNET;

async fn run() -> ClientResult<()> {
	let client = SolanaRpcClient::new(DEVNET);
	let address = pubkey!("99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ");

	client
		.request_airdrop(&address, sol_to_lamports(1.0))
		.await?;
	let account = client.get_account(&address).await?;

	log::info!("account: {account:#?}");

	Ok(())
}

Dependencies

~29–44MB
~676K SLoC