class Solana::Client
Client
class for interacting with the Solana
JSON RPC API over HTTP and WS.
Public Class Methods
Initializes a new Client
.
@param [String, nil] api_key Optional API key for authentication.
# File lib/solana-ruby/client.rb, line 16 def initialize(api_endpoint = Solana::Utils::MAINNET, api_key = nil) @api_key = api_key @api_endpoint = api_endpoint end
Public Instance Methods
Subscribes to account changes.
@param [String] pubkey The public key of the account. @param [Hash] options Optional parameters for the subscription. @yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 534 def account_subscribe(pubkey, options = {}, &block) request_ws('accountSubscribe', [pubkey, options], &block) end
Unsubscribes from account changes.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 543 def account_unsubscribe(subscription_id, &block) request_ws('accountUnsubscribe', [subscription_id], &block) end
Subscribes to new blocks.
@param [Hash] options Optional parameters for the subscription. @yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 552 def block_subscribe(options = {}, &block) request_ws('blockSubscribe', [options], &block) end
Unsubscribes from new blocks.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 561 def block_unsubscribe(subscription_id, &block) request_ws('blockUnsubscribe', [subscription_id], &block) end
Retrieves account information for a given public key.
@param [String] pubkey The public key of the account. @param [Hash] options Optional parameters for the request. @return [Hash] The account information.
# File lib/solana-ruby/client.rb, line 27 def get_account_info(pubkey, options = {}, &block) request_http('getAccountInfo', [pubkey, options], &block) end
Retrieves the balance for a given public key.
@param [String] pubkey The public key of the account. @param [Hash] options Optional parameters for the request. @return [Integer] The balance in lamports.
# File lib/solana-ruby/client.rb, line 37 def get_balance(pubkey, options = {}, &block) request_http('getBalance', [pubkey, options], &block) end
Retrieves information about a specific block.
@param [Integer] slot_number The slot number of the block. @param [Hash] options Optional parameters for the request. @return [Hash] The block information.
# File lib/solana-ruby/client.rb, line 47 def get_block(slot_number, options = {}, &block) request_http('getBlock', [slot_number, options], &block) end
Retrieves block commitment information for a specific block.
@param [Integer] slot_number The slot number of the block. @param [Hash] options Optional parameters for the request. @return [Hash] The block commitment information.
# File lib/solana-ruby/client.rb, line 57 def get_block_commitment(slot_number, options = {}, &block) request_http('getBlockCommitment', [slot_number, options], &block) end
Retrieves the current block height.
@param [Hash] options Optional parameters for the request. @return [Integer] The current block height.
# File lib/solana-ruby/client.rb, line 66 def get_block_height(options = {}, &block) request_http('getBlockHeight', [options], &block) end
Retrieves block production information.
@param [Hash] options Optional parameters for the request. @return [Hash] The block production information.
# File lib/solana-ruby/client.rb, line 75 def get_block_production(options = {}, &block) request_http('getBlockProduction', [options], &block) end
Retrieves the estimated production time of a specific block.
@param [Integer] slot_number The slot number of the block. @param [Hash] options Optional parameters for the request. @return [Integer] The estimated production time in seconds.
# File lib/solana-ruby/client.rb, line 85 def get_block_time(slot_number, options = {}, &block) request_http('getBlockTime', [slot_number, options], &block) end
Retrieves a list of confirmed blocks between two slot numbers.
@param [Integer] start_slot The start slot number. @param [Integer] end_slot The end slot number. @param [Hash] options Optional parameters for the request. @return [Array<Integer>] The list of confirmed blocks.
# File lib/solana-ruby/client.rb, line 96 def get_blocks(start_slot, end_slot, options = {}, &block) request_http('getBlocks', [start_slot, end_slot, options], &block) end
Retrieves a list of confirmed blocks starting from a given slot number with a limit on the number of blocks.
@param [Integer] start_slot The start slot number. @param [Integer] limit The maximum number of blocks to return. @param [Hash] options Optional parameters for the request. @return [Array<Integer>] The list of confirmed blocks.
# File lib/solana-ruby/client.rb, line 107 def get_blocks_with_limit(start_slot, limit, options = {}, &block) request_http('getBlocksWithLimit', [start_slot, limit, options], &block) end
Retrieves the list of cluster nodes.
@param [Hash] options Optional parameters for the request. @return [Array<Hash>] The list of cluster nodes.
# File lib/solana-ruby/client.rb, line 116 def get_cluster_nodes(options = {}, &block) request_http('getClusterNodes', [options], &block) end
Retrieves epoch information.
@param [Hash] options Optional parameters for the request. @return [Hash] The epoch information.
# File lib/solana-ruby/client.rb, line 125 def get_epoch_info(options = {}, &block) request_http('getEpochInfo', [options], &block) end
Retrieves the epoch schedule.
@param [Hash] options Optional parameters for the request. @return [Hash] The epoch schedule.
# File lib/solana-ruby/client.rb, line 134 def get_epoch_schedule(options = {}, &block) request_http('getEpochSchedule', [options], &block) end
Retrieves the fee for a given message.
@param [String] message The message for which the fee is to be calculated. @param [Hash] options Optional parameters for the request. @return [Integer] The fee for the message.
# File lib/solana-ruby/client.rb, line 144 def get_fee_for_message(message, options = {}, &block) request_http('getFeeForMessage', [message, options], &block) end
Retrieves the slot of the first available block.
@param [Hash] options Optional parameters for the request. @return [Integer] The slot of the first available block.
# File lib/solana-ruby/client.rb, line 153 def get_first_available_block(options = {}, &block) request_http('getFirstAvailableBlock', [options], &block) end
Retrieves the genesis hash.
@param [Hash] options Optional parameters for the request. @return [String] The genesis hash.
# File lib/solana-ruby/client.rb, line 162 def get_genesis_hash(options = {}, &block) request_http('getGenesisHash', [options], &block) end
Checks the health of the node.
@param [Hash] options Optional parameters for the request. @return [String] The health status of the node.
# File lib/solana-ruby/client.rb, line 171 def get_health(options = {}, &block) request_http('getHealth', [options], &block) end
Retrieves the highest snapshot slot.
@param [Hash] options Optional parameters for the request. @return [Integer] The highest snapshot slot.
# File lib/solana-ruby/client.rb, line 180 def get_highest_snapshot_slot(options = {}, &block) request_http('getHighestSnapshotSlot', [options], &block) end
Retrieves the identity of the node.
@param [Hash] options Optional parameters for the request. @return [Hash] The identity information of the node.
# File lib/solana-ruby/client.rb, line 189 def get_identity(options = {}, &block) request_http('getIdentity', [options], &block) end
Retrieves the current inflation governor settings.
@param [Hash] options Optional parameters for the request. @return [Hash] The inflation governor settings.
# File lib/solana-ruby/client.rb, line 198 def get_inflation_governor(options = {}, &block) request_http('getInflationGovernor', [options], &block) end
Retrieves the current inflation rate.
@param [Hash] options Optional parameters for the request. @return [Hash] The inflation rate.
# File lib/solana-ruby/client.rb, line 207 def get_inflation_rate(options = {}, &block) request_http('getInflationRate', [options], &block) end
Retrieves the inflation reward for a given list of addresses.
@param [Array<String>] addresses The list of addresses. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The inflation rewards for the addresses.
# File lib/solana-ruby/client.rb, line 217 def get_inflation_reward(addresses, options = {}, &block) request_http('getInflationReward', [addresses, options], &block) end
Retrieves the largest accounts.
@param [Hash] options Optional parameters for the request. @return [Array<Hash>] The largest accounts.
# File lib/solana-ruby/client.rb, line 226 def get_largest_accounts(options = {}, &block) request_http('getLargestAccounts', [options], &block) end
Retrieves the latest blockhash.
@param [Hash] options Optional parameters for the request. @return [Hash] The latest blockhash.
# File lib/solana-ruby/client.rb, line 235 def get_latest_blockhash(options = {}, &block) request_http('getLatestBlockhash', [options], &block) end
Retrieves the leader schedule.
@param [Hash] options Optional parameters for the request. @return [Hash] The leader schedule.
# File lib/solana-ruby/client.rb, line 244 def get_leader_schedule(options = {}, &block) request_http('getLeaderSchedule', [options], &block) end
Retrieves the maximum retransmit slot.
@param [Hash] options Optional parameters for the request. @return [Integer] The maximum retransmit slot.
# File lib/solana-ruby/client.rb, line 253 def get_max_retransmit_slot(options = {}, &block) request_http('getMaxRetransmitSlot', [options], &block) end
Retrieves the maximum shred insert slot.
@param [Hash] options Optional parameters for the request. @return [Integer] The maximum shred insert slot.
# File lib/solana-ruby/client.rb, line 262 def get_max_shred_insert_slot(options = {}, &block) request_http('getMaxShredInsertSlot', [options], &block) end
Retrieves the minimum balance required for rent exemption for a given data length.
@param [Integer] data_length The length of the data in bytes. @param [Hash] options Optional parameters for the request. @return [Integer] The minimum balance for rent exemption.
# File lib/solana-ruby/client.rb, line 272 def get_minimum_balance_for_rent_exemption(data_length, options = {}, &block) request_http('getMinimumBalanceForRentExemption', [data_length, options], &block) end
Retrieves information for multiple accounts.
@param [Array<String>] pubkeys The list of public keys. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The information for the accounts.
# File lib/solana-ruby/client.rb, line 282 def get_multiple_accounts(pubkeys, options = {}, &block) request_http('getMultipleAccounts', [pubkeys, options], &block) end
Retrieves information for accounts owned by a specific program.
@param [String] pubkey The public key of the program. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The information for the program accounts.
# File lib/solana-ruby/client.rb, line 292 def get_program_accounts(pubkey, options = {}, &block) request_http('getProgramAccounts', [pubkey, options], &block) end
Retrieves recent performance samples.
@param [Hash] options Optional parameters for the request. @return [Array<Hash>] The recent performance samples.
# File lib/solana-ruby/client.rb, line 301 def get_recent_performance_samples(options = {}, &block) request_http('getRecentPerformanceSamples', [options], &block) end
Retrieves recent prioritization fees.
@param [Hash] options Optional parameters for the request. @return [Hash] The recent prioritization fees.
# File lib/solana-ruby/client.rb, line 310 def get_recent_prioritization_fees(options = {}, &block) request_http('getRecentPrioritizationFees', [options], &block) end
Retrieves the status of given transaction signatures.
@param [Array<String>] signatures The list of transaction signatures. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The status of the transaction signatures.
# File lib/solana-ruby/client.rb, line 320 def get_signature_statuses(signatures, options = {}, &block) request_http('getSignatureStatuses', [signatures, options], &block) end
Retrieves the signatures for a given address.
@param [String] address The address for which to retrieve signatures. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The signatures for the address.
# File lib/solana-ruby/client.rb, line 330 def get_signatures_for_address(address, options = {}, &block) request_http('getSignaturesForAddress', [address, options], &block) end
Retrieves the current slot.
@param [Hash] options Optional parameters for the request. @return [Integer] The current slot.
# File lib/solana-ruby/client.rb, line 339 def get_slot(options = {}, &block) request_http('getSlot', [options], &block) end
Retrieves the current slot leader.
@param [Hash] options Optional parameters for the request. @return [String] The current slot leader.
# File lib/solana-ruby/client.rb, line 348 def get_slot_leader(options = {}, &block) request_http('getSlotLeader', [options], &block) end
Retrieves the slot leaders starting from a given slot with a limit on the number of leaders.
@param [Integer] start_slot The start slot number. @param [Integer] limit The maximum number of leaders to return. @param [Hash] options Optional parameters for the request. @return [Array<String>] The slot leaders.
# File lib/solana-ruby/client.rb, line 359 def get_slot_leaders(start_slot, limit, options = {}, &block) request_http('getSlotLeaders', [start_slot, limit, options], &block) end
Retrieves the stake activation information for a given public key.
@param [String] pubkey The public key of the stake account. @param [Hash] options Optional parameters for the request. @return [Hash] The stake activation information.
# File lib/solana-ruby/client.rb, line 369 def get_stake_activation(pubkey, options = {}, &block) request_http('getStakeActivation', [pubkey, options], &block) end
Retrieves the minimum delegation for a stake account.
@param [Hash] options Optional parameters for the request. @return [Integer] The minimum delegation.
# File lib/solana-ruby/client.rb, line 378 def get_stake_minimum_delegation(options = {}, &block) request_http('getStakeMinimumDelegation', [options], &block) end
Retrieves the supply information.
@param [Hash] options Optional parameters for the request. @return [Hash] The supply information.
# File lib/solana-ruby/client.rb, line 387 def get_supply(options = {}, &block) request_http('getSupply', [options], &block) end
Retrieves the token balance for a given token account.
@param [String] pubkey The public key of the token account. @param [Hash] options Optional parameters for the request. @return [Hash] The token balance.
# File lib/solana-ruby/client.rb, line 397 def get_token_account_balance(pubkey, options = {}, &block) request_http('getTokenAccountBalance', [pubkey, options], &block) end
Retrieves token accounts by delegate.
@param [String] delegate The delegate address. @param [Hash] opts Additional options for the request. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The token accounts by delegate.
# File lib/solana-ruby/client.rb, line 408 def get_token_accounts_by_delegate(delegate, opts = {}, options = {}, &block) request_http('getTokenAccountsByDelegate', [delegate, opts, options], &block) end
Retrieves token accounts by owner.
@param [String] owner The owner address. @param [Hash] opts Additional options for the request. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The token accounts by owner.
# File lib/solana-ruby/client.rb, line 419 def get_token_accounts_by_owner(owner, opts = {}, options = {}, &block) request_http('getTokenAccountsByOwner', [owner, opts, options], &block) end
Retrieves the largest accounts for a given token.
@param [String] pubkey The public key of the token. @param [Hash] options Optional parameters for the request. @return [Array<Hash>] The largest accounts for the token.
# File lib/solana-ruby/client.rb, line 429 def get_token_largest_accounts(pubkey, options = {}, &block) request_http('getTokenLargestAccounts', [pubkey, options], &block) end
Retrieves the supply of a given token.
@param [String] pubkey The public key of the token. @param [Hash] options Optional parameters for the request. @return [Hash] The token supply.
# File lib/solana-ruby/client.rb, line 439 def get_token_supply(pubkey, options = {}, &block) request_http('getTokenSupply', [pubkey, options], &block) end
Retrieves transaction details for a given signature.
@param [String] signature The transaction signature. @param [Hash] options Optional parameters for the request. @return [Hash] The transaction details.
# File lib/solana-ruby/client.rb, line 449 def get_transaction(signature, options = {}, &block) request_http('getTransaction', [signature, options], &block) end
Retrieves the total number of transactions processed by the network.
@param [Hash] options Optional parameters for the request. @return [Integer] The total number of transactions.
# File lib/solana-ruby/client.rb, line 458 def get_transaction_count(options = {}, &block) request_http('getTransactionCount', [options], &block) end
Retrieves the current version of the Solana
software.
@return [Hash] The current version information.
# File lib/solana-ruby/client.rb, line 466 def get_version(&block) request_http('getVersion', &block) end
Retrieves the list of vote accounts.
@param [Hash] options Optional parameters for the request. @return [Hash] The list of vote accounts.
# File lib/solana-ruby/client.rb, line 475 def get_vote_accounts(options = {}, &block) request_http('getVoteAccounts', [options], &block) end
Checks if a given blockhash is valid.
@param [String] blockhash The blockhash to check. @param [Hash] options Optional parameters for the request. @return [Boolean] Whether the blockhash is valid.
# File lib/solana-ruby/client.rb, line 485 def is_blockhash_valid(blockhash, options = {}, &block) request_http('isBlockhashValid', [blockhash, options], &block) end
Subscribes to log messages.
@param [String, Hash] filter The filter for log messages (e.g., a public key or a set of options). @param [Hash] options Optional parameters for the subscription. @yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 571 def logs_subscribe(filter, options = {}, &block) request_ws('logsSubscribe', [filter, options], &block) end
Unsubscribes from log messages.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 580 def logs_unsubscribe(subscription_id, &block) request_ws('logsUnsubscribe', [subscription_id], &block) end
Retrieves the minimum ledger slot.
@param [Hash] options Optional parameters for the request. @return [Integer] The minimum ledger slot.
# File lib/solana-ruby/client.rb, line 494 def minimum_ledger_slot(options = {}, &block) request_http('minimumLedgerSlot', [options], &block) end
Subscribes to program changes.
@param [String] pubkey The public key of the program. @param [Hash] options Optional parameters for the subscription. @yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 590 def program_subscribe(pubkey, options = {}, &block) request_ws('programSubscribe', [pubkey, options], &block) end
Unsubscribes from program changes.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 599 def program_unsubscribe(subscription_id, &block) request_ws('programUnsubscribe', [subscription_id], &block) end
Requests an airdrop to a given public key.
@param [String] pubkey The public key to receive the airdrop. @param [Integer] lamports The amount of lamports to airdrop. @param [Hash] options Optional parameters for the request. @return [Hash] The airdrop request response.
# File lib/solana-ruby/client.rb, line 505 def request_airdrop(pubkey, lamports, options = {}, &block) request_http('requestAirdrop', [pubkey, lamports, options], &block) end
Subscribes to root changes.
@yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 607 def root_subscribe(&block) request_ws('rootSubscribe', &block) end
Unsubscribes from root changes.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 616 def root_unsubscribe(subscription_id, &block) request_ws('rootUnsubscribe', [subscription_id], &block) end
Sends a transaction.
@param [Hash] transaction The transaction to send. @return [Hash] The response from the send transaction request.
# File lib/solana-ruby/client.rb, line 514 def send_transaction(transaction, &block) request_http('sendTransaction', [transaction.to_json], &block) end
Subscribes to signature status changes.
@param [String] signature The signature to monitor. @param [Hash] options Optional parameters for the subscription. @yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 626 def signature_subscribe(signature, options = {}, &block) request_ws('signatureSubscribe', [signature, options], &block) end
Unsubscribes from signature status changes.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 635 def signature_unsubscribe(subscription_id, &block) request_ws('signatureUnsubscribe', [subscription_id], &block) end
Simulates a transaction.
@param [Hash] transaction The transaction to simulate. @param [Hash] options Optional parameters for the request. @return [Hash] The simulation response.
# File lib/solana-ruby/client.rb, line 524 def simulate_transaction(transaction, options = {}, &block) request_http('simulateTransaction', [transaction.to_json, options], &block) end
Subscribes to slot changes.
@yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 643 def slot_subscribe(&block) request_ws('slotSubscribe', &block) end
Unsubscribes from slot changes.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 652 def slot_unsubscribe(subscription_id, &block) request_ws('slotUnsubscribe', [subscription_id], &block) end
Subscribes to slot updates.
@yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 660 def slots_updates_subscribe(&block) request_ws('slotsUpdatesSubscribe', &block) end
Unsubscribes from slot updates.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 669 def slots_updates_unsubscribe(subscription_id, &block) request_ws('slotsUpdatesUnsubscribe', [subscription_id], &block) end
Subscribes to vote updates.
@yield [Object] The response from the subscription.
# File lib/solana-ruby/client.rb, line 677 def vote_subscribe(&block) request_ws('voteSubscribe', &block) end
Unsubscribes from vote updates.
@param [Integer] subscription_id The subscription ID. @yield [Object] The response from the unsubscription.
# File lib/solana-ruby/client.rb, line 686 def vote_unsubscribe(subscription_id, &block) request_ws('voteUnsubscribe', [subscription_id], &block) end