Crate wasm_client_solana

Source
Expand description

§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::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§

BlockProductionRange
ClientRequest
ClientResponse
Context
ErrorValue
FeeForMessageValue
GetAccountInfoRequest
Use the builder pattern to create a request for account info.
GetAccountInfoResponse
GetBalanceRequest
GetBalanceResponse
GetBlockCommitmentRequest
GetBlockCommitmentResponse
GetBlockHeightRequest
GetBlockHeightResponse
GetBlockProductionRequest
GetBlockProductionResponse
GetBlockRequest
GetBlockResponse
GetBlockTimeRequest
GetBlockTimeResponse
GetBlocksRequest
GetBlocksResponse
GetBlocksWithLimitRequest
GetBlocksWithLimitResponse
GetClusterNodesRequest
GetClusterNodesResponse
GetEpochInfoRequest
GetEpochInfoResponse
GetEpochScheduleRequest
GetEpochScheduleResponse
GetFeeForMessageRequest
GetFeeForMessageResponse
GetFirstAvailableBlockRequest
GetFirstAvailableBlockResponse
GetGenesisHashRequest
GetGenesisHashResponse
GetHealthRequest
GetHealthResponse
GetHighestSnapshotSlotRequest
GetHighestSnapshotSlotResponse
GetIdentityRequest
GetIdentityResponse
GetInflationGovernorRequest
GetInflationGovernorResponse
GetInflationRateRequest
GetInflationRateResponse
GetInflationRewardRequest
GetInflationRewardResponse
GetLargestAccountsRequest
GetLargestAccountsResponse
GetLatestBlockhashRequest
GetLatestBlockhashResponse
GetLeaderScheduleRequest
GetLeaderScheduleResponse
GetMaxRetransmitSlotRequest
GetMaxRetransmitSlotResponse
GetMinimumBalanceForRentExemptionRequest
GetMinimumBalanceForRentExemptionResponse
GetMultipleAccountsRequest
GetMultipleAccountsResponse
GetProgramAccountsRequest
GetProgramAccountsResponse
GetRecentPerformanceSamplesRequest
GetRecentPerformanceSamplesResponse
GetRecentPrioritizationFeesRequest
GetRecentPrioritizationFeesResponse
GetSignatureStatusesRequest
GetSignatureStatusesResponse
GetSignaturesForAddressRequest
GetSignaturesForAddressResponse
GetSlotLeaderRequest
GetSlotLeaderResponse
GetSlotLeadersRequest
GetSlotLeadersResponse
GetSlotRequest
GetSlotResponse
GetStakeActivationRequest
GetStakeActivationResponse
GetStakeMinimumDelegationRequest
GetStakeMinimumDelegationResponse
GetSupplyRequest
GetSupplyResponse
GetTokenAccountBalanceRequest
GetTokenAccountBalanceResponse
GetTokenAccountsByDelegateRequest
GetTokenAccountsByDelegateResponse
GetTokenAccountsByOwnerRequest
GetTokenAccountsByOwnerResponse
GetTokenLargestAccountsRequest
GetTokenLargestAccountsResponse
GetTokenSupplyRequest
GetTokenSupplyResponse
GetTransactionCountRequest
GetTransactionCountResponse
GetTransactionRequest
GetTransactionResponse
GetVersionRequest
GetVersionResponse
GetVoteAccountsRequest
GetVoteAccountsResponse
HttpProvider
IsBlockhashValidRequest
IsBlockhashValidResponse
MinimumLedgerSlotRequest
MinimumLedgerSlotResponse
RequestAirdropRequest
RequestAirdropResponse
RpcContactInfoWasm
RpcError
SendTransactionRequest
SendTransactionResponse
SimulateTransactionRequest
SimulateTransactionResponse
SimulateTransactionResponseValue
SolanaRpcClient
A client of a remote Solana node.
Subscription
A Subscription is used to managed a solana websocket rpc method.
SubscriptionParams
SubscriptionResponse
TokenLargestAccountsValue
Unsubscription
Created from a Subscription to send a message to unsubscribe.
WebSocketProvider

Enums§

ClientError
ClientWebSocketError
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§

HttpMethod
RpcProvider
ToWebSocketValue
VersionedMessageExtension
VersionedTransactionExtension
Add extensions which make it possible to partially sign a versioned transaction.
WebSocketMethod
WebSocketNotification

Functions§

initialize_address_lookup_table
Initialize a lookup table that can be used with versioned transactions.

Type Aliases§

ClientResult
SubscriptionId
SubscriptionResult
UnsubscriptionResult