Expand description
§wasm_client_solana
A wasm compatible solana rpc and pubsub client.
§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 thewasm-bindgen
crate for thejs
target. This is useful for using the crate in a browser environment.ssr
: Enables the use of thereqwest
andtokio
crates for thessr
target. This is useful for using the crate in a server or non-browser environment.zstd
: Enables the use of thezstd
as an encoding format and automatically activates thessr
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::DEVNET;
use wasm_client_solana::SolanaRpcClient;
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(())
}
Re-exports§
pub use crate::utils::spawn_local;
pub use crate::rpc_config::*;
Modules§
- nonce_
utils - Durable transaction nonce helpers.
- prelude
- rpc_
config - rpc_
filter - rpc_
response - runtime
- solana_
account_ decoder - solana_
rpc_ client_ api - solana_
transaction_ status - utils
Structs§
- Block
Production Range - Client
Request - Client
Response - Context
- Error
Value - FeeFor
Message Value - GetAccount
Info Request - Use the builder pattern to create a request for account info.
- GetAccount
Info Response - GetBalance
Request - GetBalance
Response - GetBlock
Commitment Request - GetBlock
Commitment Response - GetBlock
Height Request - GetBlock
Height Response - GetBlock
Production Request - GetBlock
Production Response - GetBlock
Request - GetBlock
Response - GetBlock
Time Request - GetBlock
Time Response - GetBlocks
Request - GetBlocks
Response - GetBlocks
With Limit Request - GetBlocks
With Limit Response - GetCluster
Nodes Request - GetCluster
Nodes Response - GetEpoch
Info Request - GetEpoch
Info Response - GetEpoch
Schedule Request - GetEpoch
Schedule Response - GetFee
ForMessage Request - GetFee
ForMessage Response - GetFirst
Available Block Request - GetFirst
Available Block Response - GetGenesis
Hash Request - GetGenesis
Hash Response - GetHealth
Request - GetHealth
Response - GetHighest
Snapshot Slot Request - GetHighest
Snapshot Slot Response - GetIdentity
Request - GetIdentity
Response - GetInflation
Governor Request - GetInflation
Governor Response - GetInflation
Rate Request - GetInflation
Rate Response - GetInflation
Reward Request - GetInflation
Reward Response - GetLargest
Accounts Request - GetLargest
Accounts Response - GetLatest
Blockhash Request - GetLatest
Blockhash Response - GetLeader
Schedule Request - GetLeader
Schedule Response - GetMax
Retransmit Slot Request - GetMax
Retransmit Slot Response - GetMinimum
Balance ForRent Exemption Request - GetMinimum
Balance ForRent Exemption Response - GetMultiple
Accounts Request - GetMultiple
Accounts Response - GetProgram
Accounts Request - GetProgram
Accounts Response - GetRecent
Performance Samples Request - GetRecent
Performance Samples Response - GetRecent
Prioritization Fees Request - GetRecent
Prioritization Fees Response - GetSignature
Statuses Request - GetSignature
Statuses Response - GetSignatures
ForAddress Request - GetSignatures
ForAddress Response - GetSlot
Leader Request - GetSlot
Leader Response - GetSlot
Leaders Request - GetSlot
Leaders Response - GetSlot
Request - GetSlot
Response - GetStake
Activation Request - GetStake
Activation Response - GetStake
Minimum Delegation Request - GetStake
Minimum Delegation Response - GetSupply
Request - GetSupply
Response - GetToken
Account Balance Request - GetToken
Account Balance Response - GetToken
Accounts ByDelegate Request - GetToken
Accounts ByDelegate Response - GetToken
Accounts ByOwner Request - GetToken
Accounts ByOwner Response - GetToken
Largest Accounts Request - GetToken
Largest Accounts Response - GetToken
Supply Request - GetToken
Supply Response - GetTransaction
Count Request - GetTransaction
Count Response - GetTransaction
Request - GetTransaction
Response - GetVersion
Request - GetVersion
Response - GetVote
Accounts Request - GetVote
Accounts Response - Http
Provider - IsBlockhash
Valid Request - IsBlockhash
Valid Response - Minimum
Ledger Slot Request - Minimum
Ledger Slot Response - Request
Airdrop Request - Request
Airdrop Response - RpcContact
Info Wasm - RpcError
- Send
Transaction Request - Send
Transaction Response - Simulate
Transaction Request - Simulate
Transaction Response - Simulate
Transaction Response Value - Solana
RpcClient - A client of a remote Solana node.
- Subscription
- A
Subscription
is used to managed a solana websocket rpc method. - Subscription
Params - Subscription
Response - Token
Largest Accounts Value - Unsubscription
- Created from a
Subscription
to send a message to unsubscribe. - WebSocket
Provider
Enums§
- Client
Error - Client
WebSocket Error - Error returned by WebSocket
Constants§
- COMPUTE_
UNIT_ DEFAULT_ LIMIT - COMPUTE_
UNIT_ MAX_ LIMIT - DEBUG
- DEFAULT_
ERROR_ CODE - DEVNET
- LOCALNET
- MAINNET
- MAX_
LOOKUP_ ADDRESSES_ PER_ TRANSACTION - MAX_
RETRIES - SLEEP_
MS - TESTNET
Traits§
- Http
Method - RpcProvider
- ToWeb
Socket Value - Versioned
Message Extension - Versioned
Transaction Extension - Add extensions which make it possible to partially sign a versioned transaction.
- WebSocket
Method - WebSocket
Notification
Functions§
- initialize_
address_ lookup_ table - Initialize a lookup table that can be used with versioned transactions.