Class: SolanaRpcRuby::MethodsWrapper

Inherits:
Object
  • Object
show all
Includes:
HelperMethods, RequestBody
Defined in:
lib/solana_rpc_ruby/methods_wrapper.rb

Overview

MethodsWrapper class serves as a wrapper for solana JSON RPC API methods. All informations about params:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HelperMethods

#blank?, #create_method_name

Methods included from RequestBody

#base_body, #create_json_body

Constructor Details

#initialize(api_client: ApiClient, cluster: SolanaRpcRuby.cluster, id: rand(1...99_999)) ⇒ MethodsWrapper

Initialize object with cluster address where requests will be sent.

Parameters:

  • api_client (ApiClient) (defaults to: ApiClient)
  • cluster (String) (defaults to: SolanaRpcRuby.cluster)

    cluster where requests will be sent.

  • id (Integer) (defaults to: rand(1...99_999))

    unique client-generated identifying integer.



31
32
33
34
35
36
37
38
39
40
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 31

def initialize(
  api_client: ApiClient, 
  cluster: SolanaRpcRuby.cluster,
  id: rand(1...99_999)
)

  @api_client = api_client.new(cluster)
  @cluster = cluster
  @id = id
end

Instance Attribute Details

#api_clientSolanaRpcRuby::ApiClient

Determines which cluster will be used to send requests.



16
17
18
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 16

def api_client
  @api_client
end

#clusterString

Cluster where requests will be sent.

Returns:

  • (String)


20
21
22
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 20

def cluster
  @cluster
end

#idInteger

Unique client-generated identifying integer.

Returns:

  • (Integer)


24
25
26
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 24

def id
  @id
end

Instance Method Details

#get_account_info(account_pubkey, encoding: '', data_slice: {}) ⇒ Response, ApiError

Returns all information associated with the account of provided Pubkey

Parameters:

  • account_pubkey (String)
  • encoding (String) (defaults to: '')
  • data_slice (Hash) (defaults to: {})

Options Hash (data_slice:):

  • :offset (Integer)
  • :length (Integer)

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 52

def (, encoding: '', data_slice: {})
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['encoding'] = encoding unless blank?(encoding)
  params_hash['dataSlice'] = data_slice unless data_slice.empty?

  params << 
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_balance(account_pubkey, commitment: nil) ⇒ Response, ApiError

Returns the balance of the account of provided Pubkey

Parameters:

  • account_pubkey (String)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 77

def get_balance(, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << 
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_block(slot, encoding: '', transaction_details: '', rewards: true, commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlock for solana-core v1.6 Returns identity and transaction information about a confirmed block in the ledger

Parameters:

  • slot (Integer)
  • encoding (String) (defaults to: '')
  • transaction_details (String) (defaults to: '')
  • rewards (Boolean) (defaults to: true)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 106

def get_block(slot, encoding: '', transaction_details: '', rewards: true, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params_hash = {}
  params_hash['encoding'] = encoding unless blank?(encoding)
  params_hash['transactionDetails'] = transaction_details unless blank?(transaction_details)
  params_hash['rewards'] = rewards unless rewards.nil?
  params_hash['commitment'] = commitment unless blank?(commitment)

  params << slot
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_block_commitment(block) ⇒ Response, ApiError

Returns commitment for particular block

Parameters:

  • block (Integer)

Returns:

See Also:



184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 184

def get_block_commitment(block)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params << block

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_block_height(commitment: nil) ⇒ Response, ApiError

Returns the current block height of the node

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 132

def get_block_height(commitment: nil)
  http_method = :post
  method = create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_block_production(identity: nil, range: {}, commitment: nil) ⇒ Response, ApiError

Returns recent block production information from the current or previous epoch.

Parameters:

  • identity (String) (defaults to: nil)
  • range (Hash) (defaults to: {})
  • commitment (String) (defaults to: nil)

Options Hash (range:):

  • first_slot (Integer) — default: required for range
  • last_slot (Integer) — default: optional for range

Returns:

See Also:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 157

def get_block_production(identity: nil, range: {}, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}
  range_hash = {}

  range_hash['firstSlot'] = range[:first_slot] unless !range.key?(:first_slot)
  range_hash['lastSlot'] = range[:last_slot] unless !range.key?(:last_slot)

  params_hash['identity'] = identity unless blank?(identity)
  params_hash['range'] = range_hash unless range_hash.empty?

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_block_time(block) ⇒ Response, ApiError

Returns the estimated production time of a block.

Parameters:

  • block (Integer)

Returns:

See Also:



252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 252

def get_block_time(block)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params << block

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_blocks(start_slot, end_slot: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocks for solana-core v1.6 Returns a list of confirmed blocks between two slots

Parameters:

  • start_slot (Integer)
  • end_slot (Integer) (defaults to: nil)

Returns:

See Also:



205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 205

def get_blocks(start_slot, end_slot: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params << start_slot
  params << end_slot unless end_slot.nil?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_blocks_with_limit(start_slot, limit, commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocks for solana-core v1.6 Returns a list of confirmed blocks starting at the given slot

Parameters:

  • start_slot (Integer)
  • limit (Integer)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 228

def get_blocks_with_limit(start_slot, limit, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << start_slot
  params << limit
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_cluster_nodesResponse, ApiError

Returns information about all the nodes participating in the cluster

Returns:

See Also:



269
270
271
272
273
274
275
276
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 269

def get_cluster_nodes
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_confirmed_blocks(start_slot, end_slot: nil) ⇒ Response, ApiError

DEPRECATED: Please use getBlocks instead This method is expected to be removed in solana-core v1.8 Returns a list of confirmed blocks between two slots

Parameters:

  • start_slot (Integer)
  • end_slot (Integer) (defaults to: nil)

Returns:

See Also:



286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 286

def get_confirmed_blocks(start_slot, end_slot: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params << start_slot
  params << end_slot unless end_slot.nil? # optional

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_epoch_info(commitment: nil) ⇒ Response, ApiError

Returns information about the current epoch

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 306

def get_epoch_info(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_epoch_scheduleResponse, ApiError

Returns epoch schedule information from this cluster’s genesis config

Returns:

See Also:



326
327
328
329
330
331
332
333
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 326

def get_epoch_schedule
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_fee_calculator_for_blockhash(query_blockhash, commitment: nil) ⇒ Response, ApiError

Returns the fee calculator associated with the query blockhash, or null if the blockhash has expired

Parameters:

  • query_blockhash (String)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 342

def get_fee_calculator_for_blockhash(query_blockhash, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << query_blockhash
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_fee_rate_governorResponse, ApiError

Returns the fee rate governor information from the root bank

Returns:

See Also:



363
364
365
366
367
368
369
370
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 363

def get_fee_rate_governor
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_fees(commitment: nil) ⇒ Response, ApiError

Returns a recent block hash from the ledger, a fee schedule that can be used to compute the cost of submitting a transaction using it, and the last slot in which the blockhash will be valid.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 379

def get_fees(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_first_available_blockResponse, ApiError

Returns the slot of the lowest confirmed block that has not been purged from the ledger

Returns:

See Also:



398
399
400
401
402
403
404
405
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 398

def get_first_available_block
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_genesis_hashResponse, ApiError

Returns the genesis hash.

Returns:

See Also:



411
412
413
414
415
416
417
418
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 411

def get_genesis_hash
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_healthResponse, ApiError

Returns the current health of the node.

Returns:

See Also:



424
425
426
427
428
429
430
431
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 424

def get_health
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_identityResponse, ApiError

Returns the identity pubkey for the current node.

Returns:

See Also:



437
438
439
440
441
442
443
444
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 437

def get_identity
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_inflation_governor(commitment: nil) ⇒ Response, ApiError

Returns the current inflation governor.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 452

def get_inflation_governor(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_inflation_rateResponse, ApiError

Returns the specific inflation values for the current epoch.

Returns:

See Also:



472
473
474
475
476
477
478
479
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 472

def get_inflation_rate
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_inflation_reward(addresses, commitment: nil, epoch: nil) ⇒ Response, ApiError

Returns the inflation reward for a list of addresses for an epoch.

Parameters:

  • addresses (Array)
  • commitment (String) (defaults to: nil)
  • epoch (Integer) (defaults to: nil)

Returns:

See Also:



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 489

def get_inflation_reward(addresses, commitment: nil, epoch: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params << addresses

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['epoch'] = epoch unless epoch.nil?

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_largest_accounts(commitment: nil, filter: '') ⇒ Response, ApiError

Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)

Parameters:

  • commitment (String) (defaults to: nil)
  • filter (String) (defaults to: '')

Returns:

See Also:



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 515

def get_largest_accounts(commitment: nil, filter: '')
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['filter'] = filter unless filter.empty?

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_leader_schedule(epoch: nil, commitment: nil, identity: '') ⇒ Response, ApiError

Returns the leader schedule for an epoch.

Parameters:

  • epoch (Integer) (defaults to: nil)
  • commitment (String) (defaults to: nil)
  • identity (String) (defaults to: '')

Returns:

See Also:



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 540

def get_leader_schedule(epoch: nil, commitment: nil, identity: '')
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['epoch'] = epoch unless epoch.nil?
  params_hash['identity'] = identity unless identity.empty?
  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_max_retransmit_slotResponse, ApiError

Get the max slot seen from retransmit stage.

Returns:

See Also:



562
563
564
565
566
567
568
569
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 562

def get_max_retransmit_slot
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_max_shred_insert_slotResponse, ApiError

Get the max slot seen from after shred insert.

Returns:

See Also:



575
576
577
578
579
580
581
582
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 575

def get_max_shred_insert_slot
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_minimum_balance_for_rent_exemption(account_data_length, commitment: nil) ⇒ Response, ApiError

Returns minimum balance required to make account rent exempt.

Parameters:

  • account_data_length (String)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 591

def get_minimum_balance_for_rent_exemption(
      ,
      commitment: nil
    )
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << 
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_multiple_accounts(pubkeys, commitment: nil, encoding: '', data_slice: {}) ⇒ Response, ApiError

Parameters:

  • commitment (String) (defaults to: nil)
  • commitment (String) (defaults to: nil)

Returns:

  • (Response, ApiError)

    Response when success, ApiError on failure. # @param account_data_length [String]

  • (Response, ApiError)

    Response when success, ApiError on failure.



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 620

def get_multiple_accounts(
      pubkeys,
      commitment: nil,
      encoding: '',
      data_slice: {}
    )
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['encoding'] = encoding unless blank?(encoding)
  params_hash['dataSlice'] = data_slice unless data_slice.empty?

  params << pubkeys
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_program_accounts(pubkey, commitment: nil, encoding: '', data_slice: {}, filters: [], with_context: false) ⇒ Response, ApiError

Returns all accounts owned by the provided program Pubkey

Parameters:

  • pubkey (String)
  • commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')
  • data_slice (Hash) (defaults to: {})
  • filters (Array<Hash, Hash>) (defaults to: [])
  • with_context (Boolean) (defaults to: false)

Options Hash (data_slice:):

  • :offset (Integer)
  • :length (Integer)

Options Hash (filters:):

  • * (Hash<String, Integer>)

    dataSize, Integer, 1

  • * (Hash<String, Hash>)

    memcmp, Hash<String, Object>

    * offset, Integer, 1
    * bytes, String, '3Mc6vR'
    

Returns:

See Also:



663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 663

def get_program_accounts(
      pubkey,
      commitment: nil,
      encoding: '',
      data_slice: {},
      filters: [],
      with_context: false
    )
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['encoding'] = encoding unless blank?(encoding)
  params_hash['dataSlice'] = data_slice unless data_slice.empty?
  params_hash['filters'] = filters unless filters.empty?
  params_hash['withContext'] = with_context

  params << pubkey
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_recent_blockhash(commitment: nil) ⇒ Response, ApiError

Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 698

def get_recent_blockhash(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_recent_performance_samples(limit: nil) ⇒ Response, ApiError

Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.

Parameters:

  • limit (Integer) (defaults to: nil)

Returns:

See Also:



721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 721

def get_recent_performance_samples(limit: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []

  params << limit unless limit.nil?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_signature_statuses(transaction_signatures, search_transaction_history: false) ⇒ Response, ApiError

Returns the statuses of a list of signatures. Unless the searchTransactionHistory configuration parameter is included, this method only searches the recent status cache of signatures, which retains statuses for all active slots plus MAX_RECENT_BLOCKHASHES rooted slots.

Parameters:

  • transaction_signatures (Array)
  • search_transaction_history (Boolean) (defaults to: false)

Returns:

See Also:



798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 798

def get_signature_statuses(
      transaction_signatures,
      search_transaction_history: false
    )
  http_method = :post
  method = create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['searchTransactionHistory'] = search_transaction_history unless search_transaction_history.nil?

  params << transaction_signatures
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_signatures_for_address(account_address, limit: nil, before: '', until_: '', commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedSignaturesForAddress2 for solana-core v1.6

Returns confirmed signatures for transactions involving an address backwards in time from the provided signature or most recent confirmed block

Parameters:

  • account_address (String)
  • limit (Integer) (defaults to: nil)
  • before (String) (defaults to: '')
  • until_ (String) (defaults to: '')
  • commitment (String) (defaults to: nil)

Returns:

See Also:



761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 761

def get_signatures_for_address(
      ,
      limit: nil,
      before: '',
      until_: '',
      commitment: nil
    )
  http_method = :post
  method = create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['limit'] = limit unless limit.nil?
  params_hash['before'] = before unless before.empty?
  params_hash['until'] = until_ unless until_.empty?
  params_hash['commitment'] = commitment unless blank?(commitment)

  params << 
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_slot(commitment: nil) ⇒ Response, ApiError

Returns the current slot the node is processing.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 824

def get_slot(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_slot_leader(commitment: nil) ⇒ Response, ApiError

Returns the current slot leader

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 846

def get_slot_leader(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_slot_leaders(start_slot, limit) ⇒ Response, ApiError

Returns the slot leaders for a given slot range.

Parameters:

  • start_slot (Integer)
  • limit (Integer)

Returns:

See Also:



869
870
871
872
873
874
875
876
877
878
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 869

def get_slot_leaders(start_slot, limit)
  http_method = :post
  method =  create_method_name(__method__)

  params = [start_slot, limit]

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_snapshot_slotResponse, ApiError

Returns the highest slot that the node has a snapshot for.

Returns:

See Also:



738
739
740
741
742
743
744
745
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 738

def get_snapshot_slot
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_stake_activation(pubkey, commitment: nil, epoch: nil) ⇒ Response, ApiError

Returns epoch activation information for a stake account.

Parameters:

  • pubkey (String)
  • commitment (String) (defaults to: nil)
  • epoch (Integer) (defaults to: nil)

Returns:

See Also:



888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 888

def get_stake_activation(pubkey, commitment: nil, epoch: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['epoch'] = epoch unless epoch.nil?

  params << pubkey
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_supply(commitment: nil) ⇒ Response, ApiError

Returns information about the current supply.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 912

def get_supply(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_token_account_balance(token_account_pubkey, commitment: nil) ⇒ Response, ApiError

Returns the token balance of an SPL Token account.

Parameters:

  • token_account_pubkey (String)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 936

def (, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << 
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_token_accounts_by_delegate(token_account_pubkey, mint: '', program_id: '', commitment: nil, encoding: '', data_slice: {}) ⇒ Response, ApiError

Returns all SPL Token accounts by approved Delegate.

IMPORTANT: According to docs there should be mint or program_id passed in, not both.

Parameters:

  • token_account_pubkey (String)
  • mint (String) (defaults to: '')
  • program_id (String) (defaults to: '')
  • commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')
  • data_slice (Hash) (defaults to: {})

Options Hash (data_slice:):

  • :offset (Integer)
  • :length (Integer)

Returns:

Raises:

  • (ArgumentError)

See Also:



969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 969

def get_token_accounts_by_delegate(
      ,
      mint: '',
      program_id: '',
      commitment: nil,
      encoding: '',
      data_slice: {}
    )

  raise ArgumentError, 'You should pass mint or program_id, not both.' if !blank?(mint) && !blank?(program_id)

  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}
  params_hash_2 = {}

  params_hash['mint'] = mint unless blank?(mint)
  params_hash['programId'] = program_id unless blank?(program_id)

  params_hash_2['commitment'] = commitment unless blank?(commitment)
  params_hash_2['encoding'] = encoding unless blank?(encoding)
  params_hash_2['dataSlice'] = data_slice unless blank?(data_slice)

  params << 
  params << params_hash unless params_hash.empty?
  params << params_hash_2 if params_hash_2.any?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_token_accounts_by_owner(token_account_pubkey, mint: '', program_id: '', commitment: nil, encoding: '', data_slice: {}) ⇒ Response, ApiError

Returns all SPL Token accounts by token owner.

IMPORTANT: According to docs there should be mint or program_id passed in, not both.

Parameters:

  • token_account_pubkey (String)
  • mint (String) (defaults to: '')
  • program_id (String) (defaults to: '')
  • commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')
  • data_slice (Hash) (defaults to: {})

Options Hash (data_slice:):

  • :offset (Integer)
  • :length (Integer)

Returns:

Raises:

  • (ArgumentError)

See Also:



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1019

def get_token_accounts_by_owner(
      ,
      mint: '',
      program_id: '',
      commitment: nil,
      encoding: '',
      data_slice: {}
    )

  raise ArgumentError, 'You should pass mint or program_id, not both.' if !mint.empty? && !program_id.empty?

  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}
  params_hash_2 = {}
  param_data_slice = {}

  params_hash['mint'] = mint unless mint.empty?
  params_hash['programId'] = program_id unless program_id.empty?

  params_hash_2['commitment'] = commitment unless blank?(commitment)
  params_hash_2['encoding'] = encoding unless blank?(encoding)
  params_hash_2['dataSlice'] = data_slice unless data_slice.empty?

  params << 
  params << params_hash unless params_hash.empty?
  params << params_hash_2 unless params_hash_2.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_token_largest_accounts(token_mint_pubkey, commitment: nil) ⇒ Response, ApiError

Returns the 20 largest accounts of a particular SPL Token type.

Parameters:

  • token_mint_pubkey (String)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1062

def get_token_largest_accounts(
      token_mint_pubkey,
      commitment: nil
    )

  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << token_mint_pubkey
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_transaction(transaction_signature, encoding: '', commitment: nil) ⇒ Response, ApiError

Returns transaction details for a confirmed transaction

Parameters:

  • transaction_signature (String)
  • encoding (String) (defaults to: '')
  • commitment (String) (defaults to: nil)

Returns:

See Also:



1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1092

def get_transaction(transaction_signature, encoding: '', commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['encoding'] = encoding unless blank?(encoding)

  params << transaction_signature
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_transaction_count(commitment: nil) ⇒ Response, ApiError

Returns the current Transaction count from the ledger

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1117

def get_transaction_count(commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#get_versionResponse, ApiError

Returns the current solana versions running on the node.

Returns:

See Also:



1138
1139
1140
1141
1142
1143
1144
1145
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1138

def get_version
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_vote_accounts(commitment: nil, vote_pubkey: nil) ⇒ Response, ApiError

Returns the account info and associated stake for all the voting accounts in the current bank.

Parameters:

  • commitment (String) (defaults to: nil)
  • vote_pubkey (String) (defaults to: nil)

Returns:

See Also:



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1154

def get_vote_accounts(commitment: nil, vote_pubkey: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['votePubkey'] = vote_pubkey unless blank?(vote_pubkey)
  params_hash['commitment'] = commitment unless blank?(commitment)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#minimum_ledger_slotResponse, ApiError

Returns the lowest slot that the node has information about in its ledger. This value may increase over time if the node is configured to purge older ledger data

Returns:

See Also:



1191
1192
1193
1194
1195
1196
1197
1198
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1191

def minimum_ledger_slot
  http_method = :post
  method =  create_method_name(__method__)

  body = create_json_body(method)

  send_request(body, http_method)
end

#request_airdrop(pubkey, lamports, commitment: nil) ⇒ Response, ApiError

Requests an airdrop of lamports to a Pubkey

Parameters:

  • pubkey (String)
  • lamports (Integer)
  • commitment (String) (defaults to: nil)

Returns:

See Also:



1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1209

def request_airdrop(pubkey, lamports, commitment: nil)
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params << pubkey
  params << lamports
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#send_transaction(transaction_signature, skip_pre_flight: false, pre_flight_commitment: nil, encoding: '') ⇒ Response, ApiError

Submits a signed transaction to the cluster for processing.

Parameters:

  • transaction_signature (String)
  • skip_pre_flight (Boolean) (defaults to: false)
  • pre_flight_commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')

Returns:

See Also:



1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1235

def send_transaction(
      transaction_signature,
      skip_pre_flight: false,
      pre_flight_commitment: nil,
      encoding: ''
    )
  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}

  params_hash['skipPreFlight'] = skip_pre_flight unless skip_pre_flight.nil?
  params_hash['preflightCommitment'] = pre_flight_commitment unless blank?(pre_flight_commitment)
  params_hash['encoding'] = encoding unless blank?(encoding)

  params << transaction_signature
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#simulate_transaction(transaction_signature, accounts_addresses, sig_verify: false, commitment: nil, encoding: '', replace_recent_blockhash: false, accounts_encoding: '') ⇒ Response, ApiError

Simulate sending a transaction accounts_addresses should be an empty array (?)

Parameters:

  • transaction_signature (String)
  • accounts_addresses (Array)
  • sig_verify (Boolean) (defaults to: false)
  • commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')
  • replace_recent_blockhash (Boolean) (defaults to: false)
  • accounts_encoding (String) (defaults to: '')

Returns:

Raises:

  • (ArgumentError)

See Also:



1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1274

def simulate_transaction(
      transaction_signature,
      accounts_addresses,
      sig_verify: false,
      commitment: nil,
      encoding: '',
      replace_recent_blockhash: false,
      accounts_encoding: ''
    )

  raise ArgumentError, 'Params sig_verify and replace_recent_blockhash cannot both be set to true.' \
    if sig_verify && replace_recent_blockhash

  http_method = :post
  method =  create_method_name(__method__)

  params = []
  params_hash = {}
  params_hash['accounts'] = {}

  params_hash['accounts']['addresses'] = accounts_addresses
  params_hash['accounts']['encoding'] = accounts_encoding unless blank?(accounts_encoding)
  params_hash['sigVerify'] = sig_verify unless sig_verify.nil?
  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['encoding'] = encoding unless blank?(encoding)
  params_hash['replaceRecentBlockhash'] = replace_recent_blockhash unless replace_recent_blockhash.nil?

  params << transaction_signature
  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end