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: {}, commitment: '') ⇒ Response, ApiError

Returns all information associated with the account of provided Pubkey

Parameters:

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

Options Hash (data_slice:):

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

Returns:

See Also:



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

def (, encoding: '', data_slice: {}, commitment: '')
  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_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_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:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 81

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, params = {}) ⇒ 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)
  • transaction_details (String)
  • rewards (Boolean)
  • commitment (String)

Returns:

See Also:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 111

def get_block(slot, params = {})
  params[:rewards] ||= true
  params[:max_supported_transaction_version] ||= 0

  http_method = :post
  method = create_method_name(__method__)

  params_build = {}
  params_build['encoding'] = params[:encoding] unless blank?(params[:encoding])
  params_build['transactionDetails'] = params[:transaction_details] unless blank?(params[:transaction_details])
  params_build['rewards'] = params[:rewards] unless params[:rewards].nil?
  params_build['commitment'] = params[:commitment] unless blank?(params[:commitment])
  params_build['maxSupportedTransactionVersion'] =
    params[:max_supported_transaction_version] unless blank?(params[:max_supported_transaction_version])

  params_request = []
  params_request << slot
  params_request << params_build unless params_build.empty?

  body = create_json_body(method, method_params: params_request)

  send_request(body, http_method)
end

#get_block_commitment(block) ⇒ Response, ApiError

Returns commitment for particular block

Parameters:

  • block (Integer)

Returns:

See Also:



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 197

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:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 142

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:



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 168

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_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_time(block) ⇒ Response, ApiError

Returns the estimated production time of a block.

Parameters:

  • block (Integer)

Returns:

See Also:



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

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, 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 between two slots

Parameters:

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

Returns:

See Also:



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

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

  params = []
  params_hash = {}

  params << start_slot
  params << end_slot unless end_slot.nil?
  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_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:



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

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:



290
291
292
293
294
295
296
297
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 290

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:



1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1416

def get_confirmed_blocks(start_slot, end_slot: nil)
  warn 'DEPRECATED: Please use getBlocks instead. This method is expected to be removed in solana-core v1.8'

  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:



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

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

Deprecated.

Please use isBlockhashValid or getFeeForMessage instead This method is expected to be removed in solana-core v2.0

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:



1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1442

def get_fee_calculator_for_blockhash(query_blockhash, commitment: nil)
  warn "DEPRECATED: Please use isBlockhashValid or getFeeForMessage instead. This method is expected to be removed in solana-core v2.0"

  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_for_message(message, commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.9 or newer. Please use getFees for solana-core v1.8

Get the fee the network will charge for a particular Message

Parameters:

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

Returns:

See Also:



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

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

  params = []
  params_hash = {}

  params << message
  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_fee_rate_governorResponse, ApiError

Deprecated.

Please check solana docs for substitution.

Returns the fee rate governor information from the root bank

Returns:

See Also:



1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1468

def get_fee_rate_governor
  warn "DEPRECATED Please check solana docs for substitution."

  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

Deprecated.

DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0

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:



1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1489

def get_fees(commitment: nil)
  warn "DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0"

  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:



366
367
368
369
370
371
372
373
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 366

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:



380
381
382
383
384
385
386
387
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 380

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:



394
395
396
397
398
399
400
401
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 394

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

  body = create_json_body(method)

  send_request(body, http_method)
end

#get_highest_snapshot_slotResponse, ApiError

NEW: This method is only available in solana-core v1.9 or newer. Please use getSnapshotSlot for solana-core v1.8

Returns the highest slot information that the node has snapshots for. This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.

Returns:

See Also:



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

def get_highest_snapshot_slot
  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:



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

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:



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

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:



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

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:



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 507

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_latest_blockhash(commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8

Returns the latest blockhash.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



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

def get_latest_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_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:



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 557

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

  params = []
  params_hash = {}

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

  params << epoch unless epoch.nil?
  unless params_hash.empty?
    params << nil if epoch.nil?
    params << params_hash
  end

  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:



583
584
585
586
587
588
589
590
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 583

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:



596
597
598
599
600
601
602
603
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 596

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:



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

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

Returns the account information for a list of Pubkeys.

Parameters:

  • pubkeys (Array)
  • commitment (String) (defaults to: nil)
  • encoding (String) (defaults to: '')
  • data_slice (Hash) (defaults to: {})

Options Hash (data_slice:):

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

Returns:

See Also:



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 645

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:



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 688

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:



1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1516

def get_recent_blockhash(commitment: nil)
  warn "DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0"
  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:



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

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_recent_prioritization_fees(addresses = []) ⇒ Response, ApiError

Returns a list of prioritization fees from recent blocks.

Parameters:

  • addresses (Array<String>) (defaults to: [])

    up to 128 account addresses

Returns:

See Also:



1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1370

def get_recent_prioritization_fees(addresses = [])
  http_method = :post
  method = create_method_name(__method__)

  params = []
  params << addresses unless addresses.empty?

  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:



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

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:



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

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:



815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 815

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:



838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 838

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:



862
863
864
865
866
867
868
869
870
871
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 862

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

Deprecated.

Please use getHighestSnapshotSlot instead This method is expected to be removed in solana-core v2.0

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

Returns:

See Also:



1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1540

def get_snapshot_slot
  warn "DEPRECATED: Please use getHighestSnapshotSlot instead This method is expected to be removed in solana-core v2.0"
  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:



882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 882

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_stake_minimum_delegation(commitment: nil) ⇒ Response, ApiError

Returns the stake minimum delegation, in lamports.

Parameters:

  • commitment (String) (defaults to: nil)

Returns:

See Also:



1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1389

def get_stake_minimum_delegation(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_supply(commitment: nil, exclude_non_circulating_accounts_list: nil) ⇒ Response, ApiError

Returns information about the current supply.

Parameters:

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

Returns:

See Also:



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

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

  params = []
  params_hash = {}

  params_hash['commitment'] = commitment unless blank?(commitment)
  params_hash['excludeNonCirculatingAccountsList'] = exclude_non_circulating_accounts_list \
    unless exclude_non_circulating_accounts_list.nil?

  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:



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

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:



967
968
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
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 967

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:



1017
1018
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
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1017

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:



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

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_token_supply(token_mint_pubkey, commitment: nil) ⇒ Response, ApiError

Returns the total supply of an SPL Token type.

Parameters:

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

Returns:

See Also:



1089
1090
1091
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 1089

def get_token_supply(
  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, max_supported_transaction_version: 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:



1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1119

def get_transaction(transaction_signature, encoding: '', commitment: nil, max_supported_transaction_version: 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_hash['maxSupportedTransactionVersion'] = max_supported_transaction_version unless blank?(max_supported_transaction_version)

  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:



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

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:



1166
1167
1168
1169
1170
1171
1172
1173
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1166

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, keep_unstaked_delinquents: nil, delinquent_slot_distance: 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)
  • keep_unstaked_delinquents (Boolean) (defaults to: nil)
  • delinquent_slot_distance (Integer) (defaults to: nil)

    NOTE: For the sake of consistency between ecosystem products, it is not recommended that this argument be specified.

Returns:

See Also:



1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1185

def get_vote_accounts(
  commitment: nil,
  vote_pubkey: nil,
  keep_unstaked_delinquents: nil,
  delinquent_slot_distance: 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_hash['keepUnstakedDelinquents'] = keep_unstaked_delinquents unless keep_unstaked_delinquents.nil?
  params_hash['delinquentSlotDistance'] = delinquent_slot_distance unless blank?(delinquent_slot_distance)

  params << params_hash unless params_hash.empty?

  body = create_json_body(method, method_params: params)

  send_request(body, http_method)
end

#is_blockhash_valid(blockhash, commitment: nil) ⇒ Response, ApiError

NEW: This method is only available in solana-core v1.9 or newer. Please use getFeeCalculatorForBlockhash for solana-core v1.8

Returns whether a blockhash is still valid or not.

Parameters:

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

Returns:

See Also:



1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1218

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

  params = []
  params_hash = {}

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

  params << blockhash
  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:



1241
1242
1243
1244
1245
1246
1247
1248
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1241

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:



1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1259

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

  params = []
  params_hash = {}
  params_hash['commitment'] = commitment unless blank?(commitment)

  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: '', max_retries: nil) ⇒ 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: '')
  • max_retries (Integer) (defaults to: nil)

Returns:

See Also:



1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1287

def send_transaction(
      transaction_signature,
      skip_pre_flight: false,
      pre_flight_commitment: nil,
      encoding: '',
      max_retries: nil
    )
  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_hash['maxRetries'] = max_retries unless blank?(max_retries)

  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:



1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
# File 'lib/solana_rpc_ruby/methods_wrapper.rb', line 1328

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