View Source Signet.Solana.RPC (Signet v1.6.0)
JSON-RPC client for Solana.
Provides typed functions for Solana RPC methods with automatic Base58 encoding of pubkeys, commitment level options, and response deserialization.
Configuration
config :signet,
solana_node: "https://api.mainnet-beta.solana.com"Examples
{:ok, balance} = Signet.Solana.RPC.get_balance(pubkey)
{:ok, slot} = Signet.Solana.RPC.get_slot()
{:ok, %{blockhash: bh}} = Signet.Solana.RPC.get_latest_blockhash()
Summary
Functions
Get account info for a pubkey. Returns nil if the account doesn't exist.
Get the SOL balance (in lamports) for an account.
Get the current block height.
Check node health. Returns :ok if healthy, {:error, ...} if unhealthy.
Get the latest blockhash and its last valid block height.
Get the minimum balance for rent exemption for a given data size.
Get account info for multiple pubkeys (max 100).
Get recent prioritization fees. Pass account addresses to see fees for transactions locking those accounts.
Get the statuses of transaction signatures (max 256).
Get the current slot.
Get the token balance for an SPL Token account.
Get all token accounts owned by a wallet.
Get a transaction by its signature.
Get the node version.
Request an airdrop of SOL (devnet/testnet only).
Send a transaction and poll for confirmation.
Send a raw JSON-RPC request to the Solana node.
Send a signed transaction to the network.
Simulate a transaction without submitting it.
Functions
Get account info for a pubkey. Returns nil if the account doesn't exist.
Options
:commitment-:processed,:confirmed, or:finalized:encoding-:base64(default),:base58,:"base64+zstd",:json_parsed
@spec get_balance( <<_::256>>, keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Get the SOL balance (in lamports) for an account.
Options
:commitment-:processed,:confirmed, or:finalized
@spec get_block_height(keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Get the current block height.
Check node health. Returns :ok if healthy, {:error, ...} if unhealthy.
@spec get_latest_blockhash(keyword()) :: {:ok, %{blockhash: binary(), last_valid_block_height: non_neg_integer()}} | {:error, term()}
Get the latest blockhash and its last valid block height.
@spec get_minimum_balance_for_rent_exemption( non_neg_integer(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Get the minimum balance for rent exemption for a given data size.
Get account info for multiple pubkeys (max 100).
Options
:commitment,:encoding- same asget_account_info/2
@spec get_recent_prioritization_fees( [<<_::256>>], keyword() ) :: {:ok, [%{slot: non_neg_integer(), prioritization_fee: non_neg_integer()}]} | {:error, term()}
Get recent prioritization fees. Pass account addresses to see fees for transactions locking those accounts.
Get the statuses of transaction signatures (max 256).
Options
:search_transaction_history- Search beyond recent status cache (default: false)
@spec get_slot(keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Get the current slot.
@spec get_token_account_balance( <<_::256>>, keyword() ) :: {:ok, %{ amount: non_neg_integer(), decimals: non_neg_integer(), ui_amount_string: String.t() }} | {:error, term()}
Get the token balance for an SPL Token account.
Returns the raw integer amount, decimal precision, and ui_amount_string
(a human-readable formatted string provided by the RPC node, e.g. "1.5"
for 1500000 with 6 decimals).
@spec get_token_accounts_by_owner(<<_::256>>, keyword(), keyword()) :: {:ok, [%{pubkey: String.t(), account: map()}]} | {:error, term()}
Get all token accounts owned by a wallet.
Requires exactly one filter: :mint (specific token) or :program_id
(all tokens under a program).
Uses jsonParsed encoding by default for structured token account data.
Examples
get_token_accounts_by_owner(wallet, mint: usdc_mint)
get_token_accounts_by_owner(wallet, program_id: Programs.token_program())
Get a transaction by its signature.
Returns nil if the transaction is not found.
Options
:commitment-:confirmedor:finalized(:processedis NOT supported):encoding-:json(default),:json_parsed,:base64,:base58
@spec get_version(keyword()) :: {:ok, %{solana_core: String.t(), feature_set: non_neg_integer()}} | {:error, term()}
Get the node version.
@spec request_airdrop(<<_::256>>, non_neg_integer(), keyword()) :: {:ok, String.t()} | {:error, term()}
Request an airdrop of SOL (devnet/testnet only).
Returns the airdrop transaction signature.
@spec send_and_confirm( Signet.Solana.Transaction.t() | binary(), keyword() ) :: {:ok, String.t()} | {:error, term()}
Send a transaction and poll for confirmation.
Options
:commitment- Confirmation level to wait for (default::confirmed):timeout- Max time to wait in ms (default: 30_000):poll_interval- Poll interval in ms (default: 500)- All options from
send_transaction/2
Send a raw JSON-RPC request to the Solana node.
Options:
:solana_node- Override the node URL:timeout- Request timeout in ms (default: 30000):id- JSON-RPC request ID (default: auto-generated)
Examples
Signet.Solana.RPC.send_rpc("getSlot", [])
{:ok, 123456789}
@spec send_transaction( binary() | Signet.Solana.Transaction.t(), keyword() ) :: {:ok, String.t()} | {:error, term()}
Send a signed transaction to the network.
Accepts a Signet.Solana.Transaction struct or raw serialized bytes.
Options
:encoding-:base64(default) or:base58:skip_preflight- Skip preflight checks (default: false):preflight_commitment- Commitment for preflight simulation:max_retries- Max retries before giving up
Returns the transaction signature (Base58 string).
@spec simulate_transaction( binary() | Signet.Solana.Transaction.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Simulate a transaction without submitting it.
Returns simulation result including logs, compute units consumed, and errors.