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?

Methods included from RequestBody

#base_body, #create_json_body

Constructor Details

#initialize(api_client: ApiClient, cluster: SolanaRpcRuby.cluster) ⇒ 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.


26
27
28
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 26

def initialize(api_client: ApiClient, cluster: SolanaRpcRuby.cluster)
  @api_client = api_client.new(cluster)
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

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:


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 40

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:


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 65

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:


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 94

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:


172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 172

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:


120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 120

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:


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 145

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:


240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 240

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:


193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 193

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:


216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 216

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:


257
258
259
260
261
262
263
264
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 257

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:


274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 274

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:


294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 294

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:


314
315
316
317
318
319
320
321
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 314

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:


330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 330

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:


351
352
353
354
355
356
357
358
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 351

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:


367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 367

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:


386
387
388
389
390
391
392
393
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 386

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:


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

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:


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

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:


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

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:


440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 440

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:


460
461
462
463
464
465
466
467
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 460

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:


477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 477

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:


503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 503

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:


528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 528

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:


550
551
552
553
554
555
556
557
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 550

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:


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

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:


579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 579

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.


608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 608

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:


651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 651

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:


686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 686

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:


709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 709

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:


786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 786

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:


749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 749

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:


812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 812

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:


834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 834

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:


857
858
859
860
861
862
863
864
865
866
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 857

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:


726
727
728
729
730
731
732
733
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 726

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:


876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 876

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:


900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 900

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:


924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 924

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:


957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 957

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:


1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1007

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:


1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1050

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:


1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1080

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:


1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1105

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:


1126
1127
1128
1129
1130
1131
1132
1133
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1126

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:


1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1142

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:


1179
1180
1181
1182
1183
1184
1185
1186
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1179

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:


1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1197

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:


1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1223

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:


1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1262

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