8 stable releases
1.18.0 | Mar 10, 2024 |
---|---|
1.17.4 | Nov 4, 2023 |
1.17.2 | Oct 17, 2023 |
1.16.5 | Jul 25, 2023 |
1.11.0-beta | Jul 19, 2022 |
#17 in #wasm-client
78 downloads per month
Used in wasi-sol
750KB
16K
SLoC
Solana WASM Client
Non-blocking implementation of WASM compatible Solana Client.
Usage
Most methods are identical to solana-client non-blocking API.
solana-sdk is exported which means you don't need to add it to your dependencies.
Example
use solana_client_wasm::{
solana_sdk::signature::{Keypair, Signer},
WasmClient,
};
// Create client
let client = WasmClient::new("https://api.devnet.solana.com");
// Get a random pubkey
let pubkey = Keypair::new().pubkey();
// Get balance
let balance = client.get_balance(&pubkey).await?; // in lamports
log::info!("Balance is {balance}"); // 0
WebSocket
Requires pubsub
crate feature to be activated.
Current implementation depends on web-sys and js-sys crates and is intended to work only in browsers.
// Create a client
let client = WasmClient::new("https://api.devnet.solana.com");
// Subscribe to changes
let id = client
.account_subscribe(pubkey, |data| {
// Handle change...
})
.await;
// Unsubscribe when its no longer being used to prevent memory leak
client.account_unsubscribe(id).await;
Dependencies
~24–39MB
~666K SLoC