#solana #web3 #wasm-client #rpc #wasm

agsol-wasm-client

Async RPC client to query the Solana blockchain

5 releases

0.0.1 Jan 10, 2022
0.0.1-alpha.5 Feb 11, 2022

#34 in #wasm-client


Used in agsol-gold-bot

MIT license

35KB
813 lines

This is an experimental crate that aims to implement a Wasm-compatible non-blocking (async) RpcClient for Solana. Currently, Solana uses its own blocking RpcClient for querying the blockchain which cannot be ported to Wasm.

This crate uses an async reqwest::Client to make RpcRequests to the blockchain. Thus, querying the blockchain can be written entirely in Rust and then it can be easily ported to Wasm using wasm_bindgen.

Examples

use agsol_wasm_client::{Net, RpcClient};
use solana_program::pubkey::Pubkey;

#[tokio::main]
async fn main() {
    let mut client = RpcClient::new(Net::Devnet);
    let balance = client
        .get_minimum_balance_for_rent_exemption(50)
        .await
        .unwrap();

    let owner = client.get_owner(&Pubkey::default()).await.unwrap();
}

When built with the wasm-factory feature enabled, this crate provides the wasm_instruction!() macro that can be used for quickly exposing a Solana Instruction factory to Wasm.

Dependencies

~21–35MB
~601K SLoC