wasm_client_solana
A WebAssembly (WASM) compatible client for interacting with the Solana RPC and PubSub APIs. It allows for sending transactions, fetching account data, subscribing to account changes, and more, from within a WASM compaitible environment like the web and serverless functions.
Installation
Add the following to your Cargo.toml:
[]
= "0.10.0"
Or use cargo add:
Building for WASM
When building your crate for the wasm32-unknown-unknown target, you need to set a specific RUSTFLAGS environment variable. This is required by the getrandom crate, a dependency used for generating random numbers, to correctly function in a WASM environment.
Alternatively you can add this to your ./.cargo/config.toml file.
[]
= [
"--cfg",
"get_random_backend=\"wasm_js\"",
]
Without this flag, you may encounter compilation errors related to getrandom.
Features
This crate provides the following features:
js: Enables the use of thewasm-bindgencrate for thejstarget. This is useful for using the crate in a browser environment.ssr: Enables the use of thereqwestandtokiocrates for thessrtarget. This is useful for using the crate in a server or non-browser environment.zstd: Enables the use of thezstdas an encoding format and automatically activates thessrtarget.
Usage
The SolanaRpcClient provides a wasm compatible client for the solana rpc and pubsub methods.
use sol_str_to_lamports;
use pubkey;
use ClientResult;
use DEVNET;
use SolanaRpcClient;
async