Class: Solana::Ruby::Kit::Rpc::Client

Overview

Solana JSON-RPC client. Mirrors TypeScript’s Rpc object created by ‘createSolanaRpc(url)`.

Includes every API method as a mixin so the class surface exactly matches the TypeScript package’s method set. The transport accessor provides sub-modules with the HTTP connection.

Examples:

rpc  = Solana::Ruby::Kit::Rpc::Client.new(Solana::Ruby::Kit::RpcTypes.devnet)
slot = rpc.get_slot
res  = rpc.get_balance(address)
puts "#{res.value} lamports at slot #{res.slot}"

Constant Summary

Constants included from Api::GetAccountInfo

Api::GetAccountInfo::SUPPORTED_ENCODINGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api::SimulateTransaction

#simulate_transaction

Methods included from Api::GetVoteAccounts

#get_vote_accounts

Methods included from Api::GetEpochInfo

#get_epoch_info

Methods included from Api::GetTokenAccountsByOwner

#get_token_accounts_by_owner

Methods included from Api::GetTokenAccountBalance

#get_token_account_balance

Methods included from Api::GetTransaction

#get_transaction

Methods included from Api::GetProgramAccounts

#get_program_accounts

Methods included from Api::GetMultipleAccounts

#get_multiple_accounts

Methods included from Api::GetMinimumBalanceForRentExemption

#get_minimum_balance_for_rent_exemption

Methods included from Api::IsBlockhashValid

#is_blockhash_valid

Methods included from Api::RequestAirdrop

#request_airdrop

Methods included from Api::SendTransaction

#send_transaction

Methods included from Api::GetSignatureStatuses

#get_signature_statuses

Methods included from Api::GetBlockHeight

#get_block_height

Methods included from Api::GetAccountInfo

#get_account_info

Methods included from Api::GetLatestBlockhash

#get_latest_blockhash

Methods included from Api::GetBalance

#get_balance

Methods included from Api::GetSlot

#get_slot

Constructor Details

#initialize(cluster_url, headers: {}, timeout: Transport::DEFAULT_TIMEOUT, open_timeout: Transport::DEFAULT_OPEN_TIMEOUT) ⇒ Client

Returns a new instance of Client.



74
75
76
77
78
79
80
# File 'lib/solana/ruby/kit/rpc/client.rb', line 74

def initialize(cluster_url, headers: {}, timeout: Transport::DEFAULT_TIMEOUT, open_timeout: Transport::DEFAULT_OPEN_TIMEOUT)
  url = cluster_url.respond_to?(:url) ? cluster_url.url : cluster_url.to_s
  @transport = T.let(
    Transport.new(url: url, headers: headers, timeout: timeout, open_timeout: open_timeout),
    Transport
  )
end

Instance Attribute Details

#transportObject (readonly)

Returns the value of attribute transport.



61
62
63
# File 'lib/solana/ruby/kit/rpc/client.rb', line 61

def transport
  @transport
end