Skip to content

Async API Client

solana.rpc.async_api

Async API client to interact with the Solana JSON RPC Endpoint.

AsyncClient

Async client class.

Parameters:

Name Type Description Default
endpoint str | None

URL of the RPC endpoint.

None
commitment Commitment | None

Default bank state to query. It can be either "finalized", "confirmed" or "processed".

None
timeout float | None

HTTP request timeout in seconds. None uses the httpx2 default.

None
extra_headers dict[str, str] | None

Extra headers to pass for HTTP request.

None
proxy str | None

Proxy URL to pass to the HTTP client.

None
rate_limit float

Maximum requests per second. 0 (default) disables rate limiting.

0
max_connections int | None

Maximum number of concurrent connections. None uses the httpx2 default.

None
max_keepalive_connections int | None

Maximum number of idle keep-alive connections. None uses the httpx2 default.

None
keepalive_expiry float | None

Idle keep-alive connection expiry in seconds. None uses the httpx2 default.

None
http2 bool

Enable HTTP/2 support.

True
max_transport_retries int

Maximum number of times to retry httpx2 transport errors.

DEFAULT_MAX_TRANSPORT_RETRIES
Source code in src/solana/rpc/async_api.py
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 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
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 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
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 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
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 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
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
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
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
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
1296
1297
1298
1299
1300
1301
class AsyncClient(_ClientCore):  # pylint: disable=too-many-public-methods
    """Async client class.

    Args:
        endpoint: URL of the RPC endpoint.
        commitment: Default bank state to query. It can be either "finalized", "confirmed" or "processed".
        timeout: HTTP request timeout in seconds. ``None`` uses the httpx2 default.
        extra_headers: Extra headers to pass for HTTP request.
        proxy: Proxy URL to pass to the HTTP client.
        rate_limit: Maximum requests per second. ``0`` (default) disables rate limiting.
        max_connections: Maximum number of concurrent connections. ``None`` uses the httpx2 default.
        max_keepalive_connections: Maximum number of idle keep-alive connections. ``None`` uses the
            httpx2 default.
        keepalive_expiry: Idle keep-alive connection expiry in seconds. ``None`` uses the httpx2 default.
        http2: Enable HTTP/2 support.
        max_transport_retries: Maximum number of times to retry httpx2 transport errors.
    """

    def __init__(
        self,
        endpoint: str | None = None,
        commitment: Commitment | None = None,
        timeout: float | None = None,
        extra_headers: dict[str, str] | None = None,
        proxy: str | None = None,
        rate_limit: float = 0,
        max_connections: int | None = None,
        max_keepalive_connections: int | None = None,
        keepalive_expiry: float | None = None,
        http2: bool = True,
        max_transport_retries: int = async_http_provider.DEFAULT_MAX_TRANSPORT_RETRIES,
    ) -> None:
        """Init API client."""
        super().__init__(commitment)
        self._provider = async_http_provider.AsyncHTTPProvider(
            endpoint,
            timeout=timeout,
            extra_headers=extra_headers,
            proxy=proxy,
            rate_limit=rate_limit,
            max_connections=max_connections,
            max_keepalive_connections=max_keepalive_connections,
            keepalive_expiry=keepalive_expiry,
            http2=http2,
            max_transport_retries=max_transport_retries,
        )

    async def __aenter__(self) -> AsyncClient:
        """Use as a context manager."""
        await self._provider.__aenter__()
        return self

    async def __aexit__(self, _exc_type, _exc, _tb):
        """Exits the context manager."""
        await self.close()

    async def close(self) -> None:
        """Use this when you are done with the client."""
        await self._provider.close()

    @overload
    async def send_rpc_request(
        self,
        request: JsonRpcRequest,
        result_type: type[TResult],
        *,
        error_parser: JsonRpcErrorParser | None = None,
    ) -> TResult: ...

    @overload
    async def send_rpc_request(
        self,
        request: JsonRpcRequest,
        result_type: Any,
        *,
        error_parser: JsonRpcErrorParser | None = None,
    ) -> Any: ...

    async def send_rpc_request(
        self,
        request: JsonRpcRequest,
        result_type: Any,
        *,
        error_parser: JsonRpcErrorParser | None = None,
    ) -> Any:
        """Send a raw JSON-RPC request and parse the result with the provided type."""
        if not isinstance(request, JsonRpcRequest):
            raise TypeError("request must be an instance of JsonRpcRequest")
        raw = await self._provider.make_request_unparsed(request)
        envelope = JsonRpcResponseEnvelope.model_validate_json(raw)
        result = envelope.unwrap_result(error_parser, method=getattr(request, "method", None))
        return TypeAdapter(result_type).validate_python(result)

    async def is_connected(self) -> bool:
        """Health check.

        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> asyncio.run(solana_client.is_connected()) # doctest: +SKIP
        True

        Returns:
            True if the client is connected.
        """
        body = self._get_health_body()
        response = await self._provider.make_request(body, GetHealthResp)
        return response.value == "ok"

    async def get_balance(self, pubkey: Pubkey, commitment: Commitment | None = None) -> GetBalanceResp:
        """Returns the balance of the account of provided Pubkey.

        Args:
            pubkey: Pubkey of account to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_balance(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP
            0
        """
        body = self._get_balance_body(pubkey, commitment)
        return await self._provider.make_request(body, GetBalanceResp)

    async def get_account_info(
        self,
        pubkey: Pubkey,
        commitment: Commitment | None = None,
        encoding: str = "base64",
        data_slice: DataSliceOptsModel | None = None,
    ) -> GetAccountInfoResp:
        """Returns all the account info for the specified public key.

        Args:
            pubkey: Pubkey of account to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            encoding: (optional) Encoding for Account data, either "base58" (slow), "base64", or
                "jsonParsed". Default is "base64".

                - "base58" is limited to Account data of less than 128 bytes.
                - "base64" will return base64 encoded data for Account data of any size.
                - "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.

                If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding,
                detectable when the data field is type. (jsonParsed encoding is UNSTABLE).
            data_slice: (optional) Option to limit the returned account data using the provided `offset`: <usize> and
                `length`: <usize> fields; only available for "base58" or "base64" encoding.

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_account_info(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP
            Account(
                Account {
                    lamports: 4104230290,
                    data.len: 0,
                    owner: 11111111111111111111111111111111,
                    executable: false,
                    rent_epoch: 371,
                },
            )
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_account_info_body(
            pubkey=pubkey,
            commitment=commitment,
            encoding=encoding,
            data_slice=data_slice,
        )
        return await self._provider.make_request(body, GetAccountInfoResp)

    async def get_account_info_json_parsed(
        self,
        pubkey: Pubkey,
        commitment: Commitment | None = None,
    ) -> GetAccountInfoMaybeJsonParsedResp:
        """Returns all the account info for the specified public key.

        If JSON formatting is not available for this account, base64 is returned.

        Args:
            pubkey: Pubkey of account to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_account_info_json_parsed(Pubkey([0] * 31 + [1]))).value.owner # doctest: +SKIP
            Pubkey(
                11111111111111111111111111111111,
            )
        """
        body = self._get_account_info_body(pubkey=pubkey, commitment=commitment, encoding="jsonParsed", data_slice=None)
        return await self._provider.make_request(body, GetAccountInfoMaybeJsonParsedResp)

    async def get_block_commitment(self, slot: int) -> GetBlockCommitmentResp:
        """Fetch the commitment for particular block.

        Args:
            slot: Block, identified by Slot.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_block_commitment(0)).total_stake # doctest: +SKIP
            497717120
        """
        body = self._get_block_commitment_body(slot)
        return await self._provider.make_request(body, GetBlockCommitmentResp)

    async def get_block_time(self, slot: int) -> GetBlockTimeResp:
        """Fetch the estimated production time of a block.

        Args:
            slot: Block, identified by Slot.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_block_time(5)).value # doctest: +SKIP
            1598400007
        """
        body = self._get_block_time_body(slot)
        return await self._provider.make_request(body, GetBlockTimeResp)

    async def get_cluster_nodes(self) -> GetClusterNodesResp:
        """Returns information about all the nodes participating in the cluster.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_cluster_nodes()).value[0].tpu # doctest: +SKIP
            '139.178.65.155:8004'
        """
        return await self._provider.make_request(self._get_cluster_nodes, GetClusterNodesResp)

    async def get_block(
        self,
        slot: int,
        encoding: str = "json",
        max_supported_transaction_version: int | None = None,
        transaction_details: TransactionDetails | None = None,
        rewards: bool | None = None,
        commitment: Commitment | None = None,
    ) -> GetBlockResp:
        """Returns identity and transaction information about a confirmed block in the ledger.

        Args:
            slot: Slot, as u64 integer.
            encoding: (optional) Encoding for the returned Transaction, either "json", "jsonParsed",
                    "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.
            max_supported_transaction_version: (optional) The max transaction version to return in
                responses. If the requested transaction is a higher version, an error will be returned
            transaction_details: (optional) Level of transaction detail to return.
            rewards: (optional) Whether to populate the rewards array.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_block(1)).value.blockhash # doctest: +SKIP
            Hash(
                EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG,
            )
        """
        body = self._get_block_body(
            slot,
            encoding,
            max_supported_transaction_version,
            transaction_details,
            rewards,
            commitment,
        )
        return await self._provider.make_request(body, GetBlockResp)

    async def get_recent_performance_samples(self, limit: int | None = None) -> GetRecentPerformanceSamplesResp:
        """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.

        Args:
            limit: Limit (optional) number of samples to return (maximum 720)

        Examples:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_recent_performance_samples(1)).value[0] # doctest: +SKIP
            RpcPerfSample(
                RpcPerfSample {
                    slot: 168036172,
                    num_transactions: 7159,
                    num_slots: 158,
                    sample_period_secs: 60,
                },
            )
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_recent_performance_samples_body(limit)
        return await self._provider.make_request(body, GetRecentPerformanceSamplesResp)

    async def get_recent_prioritization_fees(
        self, addresses: Sequence[Pubkey] | None = None
    ) -> GetRecentPrioritizationFeesResp:
        """Returns a list of recent prioritization fees, in reverse slot order.

        Args:
            addresses: Account addresses to query. If omitted, the response includes recent prioritization fees
                from the node's recent blocks.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_recent_prioritization_fees()).value[0] # doctest: +SKIP
            RpcPrioritizationFee(
                RpcPrioritizationFee {
                    slot: 348125,
                    prioritization_fee: 1000,
                },
            )
        """
        body = GetRecentPrioritizationFees(addresses)
        return await self._provider.make_request(body, GetRecentPrioritizationFeesResp)

    async def get_block_height(self, commitment: Commitment | None = None) -> GetBlockHeightResp:
        """Returns the current block height of the node.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_block_height()).value # doctest: +SKIP
            1233
        """
        body = self._get_block_height_body(commitment)
        return await self._provider.make_request(body, GetBlockHeightResp)

    async def get_blocks(self, start_slot: int, end_slot: int | None = None) -> GetBlocksResp:
        """Returns a list of confirmed blocks.

        Args:
            start_slot: Start slot, as u64 integer.
            end_slot: (optional) End slot, as u64 integer.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_blocks(5, 10)).value # doctest: +SKIP
            [5, 6, 7, 8, 9, 10]
        """
        body = self._get_blocks_body(start_slot, end_slot)
        return await self._provider.make_request(body, GetBlocksResp)

    async def get_signatures_for_address(
        self,
        account: Pubkey,
        before: Signature | None = None,
        until: Signature | None = None,
        limit: int | None = None,
        commitment: Commitment | None = None,
        min_context_slot: int | None = None,
    ) -> GetSignaturesForAddressResp:
        """Returns confirmed signatures for transactions involving an address.

        Signatures are returned backwards in time from the provided signature or
        most recent confirmed block.

        Args:
            account: Account to be queried.
            before: (optional) Start searching backwards from this transaction signature.
                If not provided the search starts from the top of the highest max confirmed block.
            until: (optional) Search until this transaction signature, if found before limit reached.
            limit: (optional) Maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
            commitment: (optional) Bank state to query. It can be either "finalized", "confirmed" or "processed".
            min_context_slot: (optional) The minimum slot that the request can be evaluated at.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> from solders.pubkey import Pubkey
            >>> pubkey = Pubkey.from_string("Vote111111111111111111111111111111111111111")
            >>> (await solana_client.get_signatures_for_address(pubkey, limit=1)).value[0].signature # doctest: +SKIP
            Signature(
                1111111111111111111111111111111111111111111111111111111111111111,
            )
        """
        body = self._get_signatures_for_address_body(account, before, until, limit, commitment, min_context_slot)
        return await self._provider.make_request(body, GetSignaturesForAddressResp)

    async def get_transaction(
        self,
        tx_sig: Signature,
        encoding: str = "json",
        commitment: Commitment | None = None,
        max_supported_transaction_version: int | None = None,
    ) -> GetTransactionResp:
        """Returns transaction details for a confirmed transaction.

        Args:
            tx_sig: Transaction signature as base-58 encoded string N encoding attempts to use program-specific
                instruction parsers to return more human-readable and explicit data in the
                `transaction.message.instructions` list.
            encoding: (optional) Encoding for the returned Transaction, either "json", "jsonParsed",
                "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            max_supported_transaction_version: (optional) The max transaction version to return in responses.
                If the requested transaction is a higher version, an error will be returned

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> from solders.signature import Signature
            >>> sig = Signature.from_string("3PtGYH77LhhQqTXP4SmDVJ85hmDieWsgXCUbn14v7gYyVYPjZzygUQhTk3bSTYnfA48vCM1rmWY7zWL3j1EVKmEy")
            >>> (await solana_client.get_transaction(sig)).value.block_time # doctest: +SKIP
            1234
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_transaction_body(tx_sig, encoding, commitment, max_supported_transaction_version)
        return await self._provider.make_request(body, GetTransactionResp)

    async def get_epoch_info(self, commitment: Commitment | None = None) -> GetEpochInfoResp:
        """Returns information about the current epoch.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_epoch_info()).value.epoch # doctest: +SKIP
            0
        """
        body = self._get_epoch_info_body(commitment)
        return await self._provider.make_request(body, GetEpochInfoResp)

    async def get_epoch_schedule(self) -> GetEpochScheduleResp:
        """Returns epoch schedule information from this cluster's genesis config.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_epoch_schedule()).value.slots_per_epoch # doctest: +SKIP
            8192
        """
        return await self._provider.make_request(self._get_epoch_schedule, GetEpochScheduleResp)

    async def get_fee_for_message(
        self, message: MessageV0, commitment: Commitment | None = None
    ) -> GetFeeForMessageResp:
        """Returns the fee for a message.

        Args:
            message: Message that the fee is requested for.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> from solders.keypair import Keypair
            >>> from solders.system_program import TransferParams, transfer
            >>> from solders.message import MessageV0
            >>> leading_zeros = [0] * 31
            >>> sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2])
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> msg = MessageV0.try_compile( # doctest: +SKIP
            ...     payer=sender.pubkey(),
            ...     instructions=[transfer(TransferParams(
            ...         from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))],
            ...     address_lookup_table_accounts=[],
            ...     recent_blockhash=(await solana_client.get_latest_blockhash()).value.blockhash,
            ... )
            >>> (await solana_client.get_fee_for_message(msg)).value # doctest: +SKIP
            5000
        """
        body = self._get_fee_for_message_body(message, commitment)
        return await self._provider.make_request(body, GetFeeForMessageResp)

    async def get_first_available_block(self) -> GetFirstAvailableBlockResp:
        """Returns the slot of the lowest confirmed block that has not been purged from the ledger.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_first_available_block()).value # doctest: +SKIP
            1
        """
        return await self._provider.make_request(self._get_first_available_block, GetFirstAvailableBlockResp)

    async def get_genesis_hash(self) -> GetGenesisHashResp:
        """Returns the genesis hash.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_genesis_hash()).value # doctest: +SKIP
            Hash(
                EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG,
            )
        """
        return await self._provider.make_request(self._get_genesis_hash, GetGenesisHashResp)

    async def get_identity(self) -> GetIdentityResp:
        """Returns the identity pubkey for the current node.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_identity()).value.identity # doctest: +SKIP
            Pubkey(
                2LVtX3Wq5bhqAYYaUYBRknWaYrsfYiXLQBHTxtHWD2mv,
            )
        """
        return await self._provider.make_request(self._get_identity, GetIdentityResp)

    async def get_inflation_governor(self, commitment: Commitment | None = None) -> GetInflationGovernorResp:
        """Returns the current inflation governor.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> await (solana_client.get_inflation_governor()).value.foundation # doctest: +SKIP
            0.05
        """
        body = self._get_inflation_governor_body(commitment)
        return await self._provider.make_request(body, GetInflationGovernorResp)

    async def get_inflation_rate(self) -> GetInflationRateResp:
        """Returns the specific inflation values for the current epoch.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_inflation_rate()).value.epoch # doctest: +SKIP
            1
        """
        return await self._provider.make_request(self._get_inflation_rate, GetInflationRateResp)

    async def get_inflation_reward(
        self,
        pubkeys: list[Pubkey],
        epoch: int | None = None,
        commitment: Commitment | None = None,
    ) -> GetInflationRewardResp:
        """Returns the inflation / staking reward for a list of addresses for an epoch.

        Args:
            pubkeys: An array of addresses to query, as base-58 encoded strings
            epoch: (optional) An epoch for which the reward occurs. If omitted, the previous epoch will be used
            commitment: Bank state to query. It can be either "finalized" or "confirmed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_inflation_reward()).value.amount # doctest: +SKIP
            2500
        """
        body = self._get_inflation_reward_body(pubkeys, epoch, commitment)
        return await self._provider.make_request(body, GetInflationRewardResp)

    async def get_largest_accounts(
        self, filter_opt: str | None = None, commitment: Commitment | None = None
    ) -> GetLargestAccountsResp:
        """Returns the 20 largest accounts, by lamport balance.

        Args:
            filter_opt: Filter results by account type; currently supported: circulating|nonCirculating.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_largest_accounts()).value[0].lamports # doctest: +SKIP
            500000000000000000
        """
        body = self._get_largest_accounts_body(filter_opt, commitment)
        return await self._provider.make_request(body, GetLargestAccountsResp)

    async def get_leader_schedule(
        self, epoch: int | None = None, commitment: Commitment | None = None
    ) -> GetLeaderScheduleResp:
        """Returns the leader schedule for an epoch.

        Args:
            epoch: Fetch the leader schedule for the epoch that corresponds to the provided slot.
                If unspecified, the leader schedule for the current epoch is fetched.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> resp = await solana_client.get_leader_schedule() # doctest: +SKIP
            >>> list(resp.value.items())[0] # doctest: +SKIP
            (Pubkey(
                HMU77m6WSL9Xew9YvVCgz1hLuhzamz74eD9avi4XPdr,
            ), [346448, 346449, 346450, 346451, 369140, 369141, 369142, 369143, 384204, 384205, 384206, 384207])
        """
        body = self._get_leader_schedule_body(epoch, commitment)
        return await self._provider.make_request(body, GetLeaderScheduleResp)

    async def get_minimum_balance_for_rent_exemption(
        self, usize: int, commitment: Commitment | None = None
    ) -> GetMinimumBalanceForRentExemptionResp:
        """Returns minimum balance required to make account rent exempt.

        Args:
            usize: Account data length.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_minimum_balance_for_rent_exemption(50)).value # doctest: +SKIP
            1238880
        """
        body = self._get_minimum_balance_for_rent_exemption_body(usize, commitment)
        return await self._provider.make_request(body, GetMinimumBalanceForRentExemptionResp)

    async def get_multiple_accounts(
        self,
        pubkeys: list[Pubkey],
        commitment: Commitment | None = None,
        encoding: str = "base64",
        data_slice: DataSliceOptsModel | None = None,
    ) -> GetMultipleAccountsResp:
        """Returns all the account info for a list of public keys.

        Args:
            pubkeys: list of Pubkeys to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            encoding: (optional) Encoding for Account data, either "base58" (slow) or "base64".

                - "base58" is limited to Account data of less than 128 bytes.
                - "base64" will return base64 encoded data for Account data of any size.

            data_slice: (optional) Option to limit the returned account data using the provided `offset`: <usize> and
                `length`: <usize> fields; only available for "base58" or "base64" encoding.

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")]
            >>> (await solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP
            1
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_multiple_accounts_body(
            pubkeys=pubkeys,
            commitment=commitment,
            encoding=encoding,
            data_slice=data_slice,
        )
        return await self._provider.make_request(body, GetMultipleAccountsResp)

    async def get_multiple_accounts_json_parsed(
        self,
        pubkeys: list[Pubkey],
        commitment: Commitment | None = None,
    ) -> GetMultipleAccountsMaybeJsonParsedResp:
        """Returns all the account info for a list of public keys.

        Args:
            pubkeys: list of Pubkeys to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")]
            >>> asyncio.run(solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP
            1
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_multiple_accounts_body(
            pubkeys=pubkeys,
            commitment=commitment,
            encoding="jsonParsed",
            data_slice=None,
        )
        return await self._provider.make_request(body, GetMultipleAccountsMaybeJsonParsedResp)

    async def get_program_accounts(  # pylint: disable=too-many-arguments
        self,
        pubkey: Pubkey,
        commitment: Commitment | None = None,
        encoding: str | None = None,
        data_slice: DataSliceOptsModel | None = None,
        filters: Sequence[int | MemcmpOptsModel] | None = None,
    ) -> GetProgramAccountsResp:
        """Returns all accounts owned by the provided program Pubkey.

        Args:
            pubkey: Pubkey of program
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            encoding: (optional) Encoding for the returned Transaction, either jsonParsed",
                "base58" (slow), or "base64".
            data_slice: (optional) Limit the returned account data using the provided `offset`: <usize> and
                `length`: <usize> fields; only available for "base58" or "base64" encoding.
            filters: (optional) Options to compare a provided series of bytes with program account data at a particular offset.
                Note: an int entry is converted to a `dataSize` filter.

        Example:
            >>> from solana.rpc.models import MemcmpOpts
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR")
            >>> pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T")
            >>> filters: list[int | MemcmpOpts] = [17, memcmp_opts]
            >>> (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP
            1
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_program_accounts_body(
            pubkey=pubkey,
            commitment=commitment,
            encoding=encoding,
            data_slice=data_slice,
            filters=filters,
        )
        return await self._provider.make_request(body, GetProgramAccountsResp)

    async def get_program_accounts_json_parsed(  # pylint: disable=too-many-arguments
        self,
        pubkey: Pubkey,
        commitment: Commitment | None = None,
        filters: Sequence[int | MemcmpOptsModel] | None = None,
    ) -> GetProgramAccountsMaybeJsonParsedResp:
        """Returns all accounts owned by the provided program Pubkey.

        Args:
            pubkey: Pubkey of program
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            filters: (optional) Options to compare a provided series of bytes with program account data at a particular offset.
                Note: an int entry is converted to a `dataSize` filter.

        Example:
            >>> from solana.rpc.models import MemcmpOpts
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR")
            >>> pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T")
            >>> filters: list[int | MemcmpOpts] = [17, memcmp_opts]
            >>> (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP
            1
        """  # noqa: E501 # pylint: disable=line-too-long
        body = self._get_program_accounts_body(
            pubkey=pubkey,
            commitment=commitment,
            encoding="jsonParsed",
            data_slice=None,
            filters=filters,
        )
        return await self._provider.make_request(body, GetProgramAccountsMaybeJsonParsedResp)

    async def get_latest_blockhash(self, commitment: Commitment | None = None) -> GetLatestBlockhashResp:
        """Returns the latest block hash from the ledger.

        Response also includes the last valid block height.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_latest_blockhash()).value # doctest: +SKIP
            RpcBlockhash {
                blockhash: Hash(
                    4TLzN2RAACFnd5TYpHcUi76pC3V1qkggRF29HWk2VLeT,
                ),
                last_valid_block_height: 158286487,
            }
        """
        body = self._get_latest_blockhash_body(commitment)
        return await self._provider.make_request(body, GetLatestBlockhashResp)

    async def get_signature_statuses(
        self, signatures: list[Signature], search_transaction_history: bool = False
    ) -> GetSignatureStatusesResp:
        """Returns the statuses of a list of signatures.

        Unless the `search_transaction_history` 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.

        Args:
            signatures: An array of transaction signatures to confirm.
            search_transaction_history: If true, a Solana node will search its ledger cache for
                any signatures not found in the recent status cache.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> raw_sigs = [
            ...     "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
            ...     "5j7s6NiJS3JAkvgkoc18WVAsiSaci2pxB2A6ueCJP4tprA2TFg9wSyTLeYouxPBJEMzJinENTkpA52YStRW5Dia7"]
            >>> sigs = [Signature.from_string(sig) for sig in raw_sigs]
            >>> (await solana_client.get_signature_statuses(sigs)).value[0].confirmations # doctest: +SKIP
            10
        """
        body = self._get_signature_statuses_body(signatures, search_transaction_history)
        return await self._provider.make_request(body, GetSignatureStatusesResp)

    async def get_slot(self, commitment: Commitment | None = None) -> GetSlotResp:
        """Returns the current slot the node is processing.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_slot()).value # doctest: +SKIP
            7515
        """
        body = self._get_slot_body(commitment)
        return await self._provider.make_request(body, GetSlotResp)

    async def get_slot_leader(self, commitment: Commitment | None = None) -> GetSlotLeaderResp:
        """Returns the current slot leader.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_slot_leader()).value # doctest: +SKIP
            Pubkey(
                dv2eQHeP4RFrJZ6UeiZWoc3XTtmtZCUKxxCApCDcRNV,
            )
        """
        body = self._get_slot_leader_body(commitment)
        return await self._provider.make_request(body, GetSlotLeaderResp)

    async def get_slot_leaders(self, start: int, limit: int) -> GetSlotLeadersResp:
        """Returns the list of slot leaders for the provided start slot and limit.

        Args:
            start: The start slot to get the slot leaders from.
            limit: The number of slot leaders to return.

        Returns:
            A list of slot leaders.
        """
        body = self._get_slot_leaders_body(start, limit)
        return await self._provider.make_request(body, GetSlotLeadersResp)

    async def get_supply(
        self,
        commitment: Commitment | None = None,
        exclude_non_circulating_accounts_list: bool = False,
    ) -> GetSupplyResp:
        """Returns information about the current supply.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            exclude_non_circulating_accounts_list: If True, exclude non-circulating accounts from supply.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_supply()).value.circulating # doctest: +SKIP
            683635192454157660
        """
        body = self._get_supply_body(commitment, exclude_non_circulating_accounts_list)
        return await self._provider.make_request(body, GetSupplyResp)

    async def get_token_account_balance(
        self, pubkey: Pubkey, commitment: Commitment | None = None
    ) -> GetTokenAccountBalanceResp:
        """Returns the token balance of an SPL Token account (UNSTABLE).

        Args:
            pubkey: Pubkey of Token account to query
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> pubkey = Pubkey.from_string("7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7")
            >>> (await solana_client.get_token_account_balance(pubkey)).value.amount  # noqa: E501 # doctest: +SKIP
            '9864'
        """
        body = self._get_token_account_balance_body(pubkey, commitment)
        return await self._provider.make_request(body, GetTokenAccountBalanceResp)

    async def get_token_accounts_by_delegate(
        self,
        delegate: Pubkey,
        opts: TokenAccountOptsModel,
        commitment: Commitment | None = None,
    ) -> GetTokenAccountsByDelegateResp:
        """Returns all SPL Token accounts by approved Delegate (UNSTABLE).

        Args:
            delegate: Public key of the delegate owner to query.
            opts: Token account option specifying at least one of `mint` or `program_id`.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        """
        body = self._get_token_accounts_by_delegate_body(delegate, opts, commitment)
        return await self._provider.make_request(body, GetTokenAccountsByDelegateResp)

    async def get_token_accounts_by_delegate_json_parsed(
        self,
        delegate: Pubkey,
        opts: TokenAccountOptsModel,
        commitment: Commitment | None = None,
    ) -> GetTokenAccountsByDelegateJsonParsedResp:
        """Returns all SPL Token accounts by approved delegate in JSON format (UNSTABLE).

        Args:
            delegate: Public key of the delegate owner to query.
            opts: Token account option specifying at least one of `mint` or `program_id`.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        """
        body = self._get_token_accounts_by_delegate_json_parsed_body(delegate, opts, commitment)
        return await self._provider.make_request(body, GetTokenAccountsByDelegateJsonParsedResp)

    async def get_token_accounts_by_owner_json_parsed(
        self,
        owner: Pubkey,
        opts: TokenAccountOptsModel,
        commitment: Commitment | None = None,
    ) -> GetTokenAccountsByOwnerJsonParsedResp:
        """Returns all SPL Token accounts by token owner in JSON format (UNSTABLE).

        Args:
            owner: Public key of the account owner to query.
            opts: Token account option specifying at least one of `mint` or `program_id`.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        """
        body = self._get_token_accounts_by_owner_json_parsed_body(owner, opts, commitment)
        return await self._provider.make_request(body, GetTokenAccountsByOwnerJsonParsedResp)

    async def get_token_accounts_by_owner(
        self,
        owner: Pubkey,
        opts: TokenAccountOptsModel,
        commitment: Commitment | None = None,
    ) -> GetTokenAccountsByOwnerResp:
        """Returns all SPL Token accounts by token owner (UNSTABLE).

        Args:
            owner: Public key of the account owner to query.
            opts: Token account option specifying at least one of `mint` or `program_id`.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        """
        body = self._get_token_accounts_by_owner_body(owner, opts, commitment)
        return await self._provider.make_request(body, GetTokenAccountsByOwnerResp)

    async def get_token_largest_accounts(
        self, pubkey: Pubkey, commitment: Commitment | None = None
    ) -> GetTokenLargestAccountsResp:
        """Returns the 20 largest accounts of a particular SPL Token type."""
        body = self._get_token_largest_accounts_body(pubkey, commitment)
        return await self._provider.make_request(body, GetTokenLargestAccountsResp)

    async def get_token_supply(self, pubkey: Pubkey, commitment: Commitment | None = None) -> GetTokenSupplyResp:
        """Returns the total supply of an SPL Token type."""
        body = self._get_token_supply_body(pubkey, commitment)
        return await self._provider.make_request(body, GetTokenSupplyResp)

    async def get_transaction_count(self, commitment: Commitment | None = None) -> GetTransactionCountResp:
        """Returns the current Transaction count from the ledger.

        Args:
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_transaction_count()).value # doctest: +SKIP
            4554
        """
        body = self._get_transaction_count_body(commitment)
        return await self._provider.make_request(body, GetTransactionCountResp)

    async def get_minimum_ledger_slot(self) -> MinimumLedgerSlotResp:
        """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.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_minimum_ledger_slot()).value # doctest: +SKIP
            1234
        """
        return await self._provider.make_request(self._minimum_ledger_slot, MinimumLedgerSlotResp)

    async def get_version(self) -> GetVersionResp:
        """Returns the current solana versions running on the node.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_version()).value.solana_core # doctest: +SKIP
            '1.13.2'
        """
        return await self._provider.make_request(self._get_version, GetVersionResp)

    async def get_vote_accounts(
        self,
        vote_pubkey: Pubkey | None = None,
        commitment: Commitment | None = None,
        keep_unstaked_delinquents: bool | None = None,
        delinquent_slot_distance: int | None = None,
    ) -> GetVoteAccountsResp:
        """Returns the account info and associated stake for all the voting accounts in the current bank.

        Args:
            vote_pubkey: Only return results for this validator vote address.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            keep_unstaked_delinquents: Filter out delinquent validators with no stake.
            delinquent_slot_distance: Specify the number of slots behind the tip that the validator must fall
                to be considered delinquent.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.get_vote_accounts()).value.current[0].commission # doctest: +SKIP
            100
        """
        body = self._get_vote_accounts_body(
            vote_pubkey, commitment, keep_unstaked_delinquents, delinquent_slot_distance
        )
        return await self._provider.make_request(body, GetVoteAccountsResp)

    async def request_airdrop(
        self, pubkey: Pubkey, lamports: int, commitment: Commitment | None = None
    ) -> RequestAirdropResp:
        """Requests an airdrop of lamports to a Pubkey.

        Args:
            pubkey: Pubkey of account to receive lamports, as base-58 encoded string or public key object.
            lamports: Amount of lamports.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

        Example:
            >>> from solders.pubkey import Pubkey
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.request_airdrop(Pubkey([0] * 31 + [1]), 10000)).value # doctest: +SKIP
            Signature(
                1111111111111111111111111111111111111111111111111111111111111111,
            )
        """
        body = self._request_airdrop_body(pubkey, lamports, commitment)
        return await self._provider.make_request(body, RequestAirdropResp)

    async def send_raw_transaction(self, txn: bytes, opts: TxOptsModel | None = None) -> SendTransactionResp:
        """Send a transaction that has already been signed and serialized into the wire format.

        Args:
            txn: Transaction bytes.
            opts: (optional) Transaction options.

        Before submitting, the following preflight checks are performed (unless disabled with the `skip_preflight` option):

            - The transaction signatures are verified.

            - The transaction is simulated against the latest max confirmed bank and on failure an error
                will be returned. Preflight checks may be disabled if desired.


        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> full_signed_tx_hex = (
            ...     '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc'
            ...     '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41'
            ...     '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000'
            ...     '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7'
            ...     '1851a106901020200010c0200000040420f0000000000'
            ... )
            >>> (await solana_client.send_raw_transaction(bytes.fromhex(full_signed_tx_hex))).value  # doctest: +SKIP
            Signature(
                1111111111111111111111111111111111111111111111111111111111111111,
            )
        """  # noqa: E501 # pylint: disable=line-too-long
        opts_to_use = TxOptsModel(preflight_commitment=self._commitment) if opts is None else opts
        body = self._send_raw_transaction_body(txn, opts_to_use)

        resp = await self._provider.make_request(body, SendTransactionResp)
        if opts_to_use.skip_confirmation:
            return self._post_send(resp)
        post_send_args = self._send_raw_transaction_post_send_args(resp, opts_to_use)
        return await self.__post_send_with_confirm(*post_send_args)

    async def send_transaction(
        self,
        txn: VersionedTransaction,
        opts: TxOptsModel | None = None,
    ) -> SendTransactionResp:
        """Send a transaction.

        Args:
            txn: transaction object.
            opts: (optional) Transaction options.

        Example:
            >>> from solders.keypair import Keypair
            >>> from solders.system_program import TransferParams, transfer
            >>> from solders.message import MessageV0
            >>> from solders.transaction import VersionedTransaction
            >>> leading_zeros = [0] * 31
            >>> sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2])
            >>> ixns = [transfer(TransferParams(
            ...     from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))]
            >>> client = AsyncClient("http://localhost:8899")
            >>> msg = MessageV0.try_compile( # doctest: +SKIP
            ...     payer=sender.pubkey(),
            ...     instructions=ixns,
            ...     address_lookup_table_accounts=[],
            ...     recent_blockhash=(await client.get_latest_blockhash()).value.blockhash,
            ... )
            >>> (await client.send_transaction(VersionedTransaction(msg, [sender]))) # doctest: +SKIP
        """
        return await self.send_raw_transaction(bytes(txn), opts=opts)

    async def simulate_transaction(
        self,
        txn: VersionedTransaction,
        sig_verify: bool = False,
        commitment: Commitment | None = None,
        replace_recent_blockhash: bool = False,
        min_context_slot: int | None = None,
        inner_instructions: bool = False,
        accounts_addresses: list[Pubkey] | None = None,
        accounts_encoding: str = "base64",
    ) -> SimulateTransactionResp:
        """Simulate sending a transaction.

        Args:
            txn: A transaction object.
            sig_verify: If True the transaction signatures will be verified
                (conflicts with ``replace_recent_blockhash``).
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            replace_recent_blockhash: If True the transaction recent blockhash
                will be replaced with the most recent blockhash
                (conflicts with ``sig_verify``).
            min_context_slot: The minimum slot that the request can be evaluated at.
            inner_instructions: If true the response will include inner instructions.
                These inner instructions will be `jsonParsed` where possible, otherwise json.
            accounts_addresses: An array of accounts to return, as base-58 encoded strings
            accounts_encoding: Encoding for returned Account data.
                Note: jsonParsed encoding attempts to use program-specific state parsers to return more
                human-readable and explicit account state data. If jsonParsed is requested but a parser
                cannot be found, the field falls back to base64 encoding, detectable when the returned
                accounts field is type string.

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> full_signed_tx_hex = (
            ...     '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc'
            ...     '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41'
            ...     '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000'
            ...     '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7'
            ...     '1851a106901020200010c0200000040420f0000000000'
            ... )
            >>> tx = VersionedTransaction.from_bytes(bytes.fromhex(full_signed_tx_hex))
            >>> (await solana_client.simulate_transaction(tx)).value.logs  # doctest: +SKIP
            ['BPF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success']
        """
        body = self._simulate_transaction_body(
            txn,
            sig_verify,
            commitment,
            replace_recent_blockhash,
            min_context_slot,
            inner_instructions,
            accounts_addresses,
            accounts_encoding,
        )
        return await self._provider.make_request(body, SimulateTransactionResp)

    async def validator_exit(self) -> ValidatorExitResp:
        """Request to have the validator exit.

        Validator must have booted with RPC exit enabled (`--enable-rpc-exit` parameter).

        Example:
            >>> solana_client = AsyncClient("http://localhost:8899")
            >>> (await solana_client.validator_exit()).value # doctest: +SKIP
            True
        """
        return await self._provider.make_request(self._validator_exit, ValidatorExitResp)  # type: ignore

    async def __post_send_with_confirm(
        self,
        resp: SendTransactionResp,
        conf_comm: Commitment,
        last_valid_block_height: int | None,
    ) -> SendTransactionResp:
        resp = self._post_send(resp)
        sig = resp.value
        self._provider.logger.info("Transaction sent to %s. Signature %s: ", self._provider.endpoint_uri, sig)
        await self.confirm_transaction(sig, conf_comm, last_valid_block_height=last_valid_block_height)
        return resp

    async def confirm_transaction(
        self,
        tx_sig: Signature,
        commitment: Commitment | None = None,
        sleep_seconds: float = 0.5,
        last_valid_block_height: int | None = None,
    ) -> GetSignatureStatusesResp:
        """Confirm the transaction identified by the specified signature.

        Args:
            tx_sig: the transaction signature to confirm.
            commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
            sleep_seconds: The number of seconds to sleep when polling the signature status.
            last_valid_block_height: The block height by which the transaction would become invalid.
        """
        commitment_to_use = _COMMITMENT_TO_SOLDERS[commitment or self._commitment]
        commitment_rank = int(commitment_to_use)
        if last_valid_block_height:  # pylint: disable=no-else-return
            current_blockheight = (await self.get_block_height(commitment)).value
            while current_blockheight <= last_valid_block_height:
                resp = await self.get_signature_statuses([tx_sig])
                resp_value = resp.value[0]
                if resp_value is not None:
                    confirmation_status = resp_value.confirmation_status
                    if confirmation_status is not None:
                        confirmation_rank = int(confirmation_status)
                        if confirmation_rank >= commitment_rank:
                            break
                current_blockheight = (await self.get_block_height(commitment)).value
                await asyncio.sleep(sleep_seconds)
            else:
                raise TransactionExpiredBlockheightExceededError(f"{tx_sig} has expired: block height exceeded")
            return resp
        else:
            timeout = time() + 90
            while time() < timeout:
                resp = await self.get_signature_statuses([tx_sig])
                resp_value = resp.value[0]
                if resp_value is not None:
                    confirmation_status = resp_value.confirmation_status
                    if confirmation_status is not None:
                        confirmation_rank = int(confirmation_status)
                        if confirmation_rank >= commitment_rank:
                            break
                await asyncio.sleep(sleep_seconds)
            else:
                raise UnconfirmedTxError(f"Unable to confirm transaction {tx_sig}")
            return resp

__init__(endpoint=None, commitment=None, timeout=None, extra_headers=None, proxy=None, rate_limit=0, max_connections=None, max_keepalive_connections=None, keepalive_expiry=None, http2=True, max_transport_retries=async_http_provider.DEFAULT_MAX_TRANSPORT_RETRIES)

Init API client.

Source code in src/solana/rpc/async_api.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
def __init__(
    self,
    endpoint: str | None = None,
    commitment: Commitment | None = None,
    timeout: float | None = None,
    extra_headers: dict[str, str] | None = None,
    proxy: str | None = None,
    rate_limit: float = 0,
    max_connections: int | None = None,
    max_keepalive_connections: int | None = None,
    keepalive_expiry: float | None = None,
    http2: bool = True,
    max_transport_retries: int = async_http_provider.DEFAULT_MAX_TRANSPORT_RETRIES,
) -> None:
    """Init API client."""
    super().__init__(commitment)
    self._provider = async_http_provider.AsyncHTTPProvider(
        endpoint,
        timeout=timeout,
        extra_headers=extra_headers,
        proxy=proxy,
        rate_limit=rate_limit,
        max_connections=max_connections,
        max_keepalive_connections=max_keepalive_connections,
        keepalive_expiry=keepalive_expiry,
        http2=http2,
        max_transport_retries=max_transport_retries,
    )

close() async

Use this when you are done with the client.

Source code in src/solana/rpc/async_api.py
150
151
152
async def close(self) -> None:
    """Use this when you are done with the client."""
    await self._provider.close()

confirm_transaction(tx_sig, commitment=None, sleep_seconds=0.5, last_valid_block_height=None) async

Confirm the transaction identified by the specified signature.

Parameters:

Name Type Description Default
tx_sig Signature

the transaction signature to confirm.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
sleep_seconds float

The number of seconds to sleep when polling the signature status.

0.5
last_valid_block_height int | None

The block height by which the transaction would become invalid.

None
Source code in src/solana/rpc/async_api.py
1254
1255
1256
1257
1258
1259
1260
1261
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
1296
1297
1298
1299
1300
1301
async def confirm_transaction(
    self,
    tx_sig: Signature,
    commitment: Commitment | None = None,
    sleep_seconds: float = 0.5,
    last_valid_block_height: int | None = None,
) -> GetSignatureStatusesResp:
    """Confirm the transaction identified by the specified signature.

    Args:
        tx_sig: the transaction signature to confirm.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        sleep_seconds: The number of seconds to sleep when polling the signature status.
        last_valid_block_height: The block height by which the transaction would become invalid.
    """
    commitment_to_use = _COMMITMENT_TO_SOLDERS[commitment or self._commitment]
    commitment_rank = int(commitment_to_use)
    if last_valid_block_height:  # pylint: disable=no-else-return
        current_blockheight = (await self.get_block_height(commitment)).value
        while current_blockheight <= last_valid_block_height:
            resp = await self.get_signature_statuses([tx_sig])
            resp_value = resp.value[0]
            if resp_value is not None:
                confirmation_status = resp_value.confirmation_status
                if confirmation_status is not None:
                    confirmation_rank = int(confirmation_status)
                    if confirmation_rank >= commitment_rank:
                        break
            current_blockheight = (await self.get_block_height(commitment)).value
            await asyncio.sleep(sleep_seconds)
        else:
            raise TransactionExpiredBlockheightExceededError(f"{tx_sig} has expired: block height exceeded")
        return resp
    else:
        timeout = time() + 90
        while time() < timeout:
            resp = await self.get_signature_statuses([tx_sig])
            resp_value = resp.value[0]
            if resp_value is not None:
                confirmation_status = resp_value.confirmation_status
                if confirmation_status is not None:
                    confirmation_rank = int(confirmation_status)
                    if confirmation_rank >= commitment_rank:
                        break
            await asyncio.sleep(sleep_seconds)
        else:
            raise UnconfirmedTxError(f"Unable to confirm transaction {tx_sig}")
        return resp

get_account_info(pubkey, commitment=None, encoding='base64', data_slice=None) async

Returns all the account info for the specified public key.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of account to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
encoding str

(optional) Encoding for Account data, either "base58" (slow), "base64", or "jsonParsed". Default is "base64".

  • "base58" is limited to Account data of less than 128 bytes.
  • "base64" will return base64 encoded data for Account data of any size.
  • "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.

If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the data field is type. (jsonParsed encoding is UNSTABLE).

'base64'
data_slice DataSliceOpts | None

(optional) Option to limit the returned account data using the provided offset: and length: fields; only available for "base58" or "base64" encoding.

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_account_info(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP Account( Account { lamports: 4104230290, data.len: 0, owner: 11111111111111111111111111111111, executable: false, rent_epoch: 371, }, )

Source code in src/solana/rpc/async_api.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
async def get_account_info(
    self,
    pubkey: Pubkey,
    commitment: Commitment | None = None,
    encoding: str = "base64",
    data_slice: DataSliceOptsModel | None = None,
) -> GetAccountInfoResp:
    """Returns all the account info for the specified public key.

    Args:
        pubkey: Pubkey of account to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        encoding: (optional) Encoding for Account data, either "base58" (slow), "base64", or
            "jsonParsed". Default is "base64".

            - "base58" is limited to Account data of less than 128 bytes.
            - "base64" will return base64 encoded data for Account data of any size.
            - "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.

            If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding,
            detectable when the data field is type. (jsonParsed encoding is UNSTABLE).
        data_slice: (optional) Option to limit the returned account data using the provided `offset`: <usize> and
            `length`: <usize> fields; only available for "base58" or "base64" encoding.

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_account_info(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP
        Account(
            Account {
                lamports: 4104230290,
                data.len: 0,
                owner: 11111111111111111111111111111111,
                executable: false,
                rent_epoch: 371,
            },
        )
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_account_info_body(
        pubkey=pubkey,
        commitment=commitment,
        encoding=encoding,
        data_slice=data_slice,
    )
    return await self._provider.make_request(body, GetAccountInfoResp)

get_account_info_json_parsed(pubkey, commitment=None) async

Returns all the account info for the specified public key.

If JSON formatting is not available for this account, base64 is returned.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of account to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_account_info_json_parsed(Pubkey([0] * 31 + [1]))).value.owner # doctest: +SKIP Pubkey( 11111111111111111111111111111111, )

Source code in src/solana/rpc/async_api.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
async def get_account_info_json_parsed(
    self,
    pubkey: Pubkey,
    commitment: Commitment | None = None,
) -> GetAccountInfoMaybeJsonParsedResp:
    """Returns all the account info for the specified public key.

    If JSON formatting is not available for this account, base64 is returned.

    Args:
        pubkey: Pubkey of account to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_account_info_json_parsed(Pubkey([0] * 31 + [1]))).value.owner # doctest: +SKIP
        Pubkey(
            11111111111111111111111111111111,
        )
    """
    body = self._get_account_info_body(pubkey=pubkey, commitment=commitment, encoding="jsonParsed", data_slice=None)
    return await self._provider.make_request(body, GetAccountInfoMaybeJsonParsedResp)

get_balance(pubkey, commitment=None) async

Returns the balance of the account of provided Pubkey.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of account to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_balance(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP 0

Source code in src/solana/rpc/async_api.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
async def get_balance(self, pubkey: Pubkey, commitment: Commitment | None = None) -> GetBalanceResp:
    """Returns the balance of the account of provided Pubkey.

    Args:
        pubkey: Pubkey of account to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_balance(Pubkey([0] * 31 + [1]))).value # doctest: +SKIP
        0
    """
    body = self._get_balance_body(pubkey, commitment)
    return await self._provider.make_request(body, GetBalanceResp)

get_block(slot, encoding='json', max_supported_transaction_version=None, transaction_details=None, rewards=None, commitment=None) async

Returns identity and transaction information about a confirmed block in the ledger.

Parameters:

Name Type Description Default
slot int

Slot, as u64 integer.

required
encoding str

(optional) Encoding for the returned Transaction, either "json", "jsonParsed", "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.

'json'
max_supported_transaction_version int | None

(optional) The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned

None
transaction_details TransactionDetails | None

(optional) Level of transaction detail to return.

None
rewards bool | None

(optional) Whether to populate the rewards array.

None
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_block(1)).value.blockhash # doctest: +SKIP Hash( EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG, )

Source code in src/solana/rpc/async_api.py
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
async def get_block(
    self,
    slot: int,
    encoding: str = "json",
    max_supported_transaction_version: int | None = None,
    transaction_details: TransactionDetails | None = None,
    rewards: bool | None = None,
    commitment: Commitment | None = None,
) -> GetBlockResp:
    """Returns identity and transaction information about a confirmed block in the ledger.

    Args:
        slot: Slot, as u64 integer.
        encoding: (optional) Encoding for the returned Transaction, either "json", "jsonParsed",
                "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.
        max_supported_transaction_version: (optional) The max transaction version to return in
            responses. If the requested transaction is a higher version, an error will be returned
        transaction_details: (optional) Level of transaction detail to return.
        rewards: (optional) Whether to populate the rewards array.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_block(1)).value.blockhash # doctest: +SKIP
        Hash(
            EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG,
        )
    """
    body = self._get_block_body(
        slot,
        encoding,
        max_supported_transaction_version,
        transaction_details,
        rewards,
        commitment,
    )
    return await self._provider.make_request(body, GetBlockResp)

get_block_commitment(slot) async

Fetch the commitment for particular block.

Parameters:

Name Type Description Default
slot int

Block, identified by Slot.

required
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_block_commitment(0)).total_stake # doctest: +SKIP 497717120

Source code in src/solana/rpc/async_api.py
287
288
289
290
291
292
293
294
295
296
297
298
299
async def get_block_commitment(self, slot: int) -> GetBlockCommitmentResp:
    """Fetch the commitment for particular block.

    Args:
        slot: Block, identified by Slot.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_block_commitment(0)).total_stake # doctest: +SKIP
        497717120
    """
    body = self._get_block_commitment_body(slot)
    return await self._provider.make_request(body, GetBlockCommitmentResp)

get_block_height(commitment=None) async

Returns the current block height of the node.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_block_height()).value # doctest: +SKIP 1233

Source code in src/solana/rpc/async_api.py
408
409
410
411
412
413
414
415
416
417
418
419
420
async def get_block_height(self, commitment: Commitment | None = None) -> GetBlockHeightResp:
    """Returns the current block height of the node.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_block_height()).value # doctest: +SKIP
        1233
    """
    body = self._get_block_height_body(commitment)
    return await self._provider.make_request(body, GetBlockHeightResp)

get_block_time(slot) async

Fetch the estimated production time of a block.

Parameters:

Name Type Description Default
slot int

Block, identified by Slot.

required
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_block_time(5)).value # doctest: +SKIP 1598400007

Source code in src/solana/rpc/async_api.py
301
302
303
304
305
306
307
308
309
310
311
312
313
async def get_block_time(self, slot: int) -> GetBlockTimeResp:
    """Fetch the estimated production time of a block.

    Args:
        slot: Block, identified by Slot.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_block_time(5)).value # doctest: +SKIP
        1598400007
    """
    body = self._get_block_time_body(slot)
    return await self._provider.make_request(body, GetBlockTimeResp)

get_blocks(start_slot, end_slot=None) async

Returns a list of confirmed blocks.

Parameters:

Name Type Description Default
start_slot int

Start slot, as u64 integer.

required
end_slot int | None

(optional) End slot, as u64 integer.

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_blocks(5, 10)).value # doctest: +SKIP [5, 6, 7, 8, 9, 10]

Source code in src/solana/rpc/async_api.py
422
423
424
425
426
427
428
429
430
431
432
433
434
435
async def get_blocks(self, start_slot: int, end_slot: int | None = None) -> GetBlocksResp:
    """Returns a list of confirmed blocks.

    Args:
        start_slot: Start slot, as u64 integer.
        end_slot: (optional) End slot, as u64 integer.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_blocks(5, 10)).value # doctest: +SKIP
        [5, 6, 7, 8, 9, 10]
    """
    body = self._get_blocks_body(start_slot, end_slot)
    return await self._provider.make_request(body, GetBlocksResp)

get_cluster_nodes() async

Returns information about all the nodes participating in the cluster.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_cluster_nodes()).value[0].tpu # doctest: +SKIP '139.178.65.155:8004'

Source code in src/solana/rpc/async_api.py
315
316
317
318
319
320
321
322
323
async def get_cluster_nodes(self) -> GetClusterNodesResp:
    """Returns information about all the nodes participating in the cluster.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_cluster_nodes()).value[0].tpu # doctest: +SKIP
        '139.178.65.155:8004'
    """
    return await self._provider.make_request(self._get_cluster_nodes, GetClusterNodesResp)

get_epoch_info(commitment=None) async

Returns information about the current epoch.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_epoch_info()).value.epoch # doctest: +SKIP 0

Source code in src/solana/rpc/async_api.py
501
502
503
504
505
506
507
508
509
510
511
512
513
async def get_epoch_info(self, commitment: Commitment | None = None) -> GetEpochInfoResp:
    """Returns information about the current epoch.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_epoch_info()).value.epoch # doctest: +SKIP
        0
    """
    body = self._get_epoch_info_body(commitment)
    return await self._provider.make_request(body, GetEpochInfoResp)

get_epoch_schedule() async

Returns epoch schedule information from this cluster's genesis config.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_epoch_schedule()).value.slots_per_epoch # doctest: +SKIP 8192

Source code in src/solana/rpc/async_api.py
515
516
517
518
519
520
521
522
523
async def get_epoch_schedule(self) -> GetEpochScheduleResp:
    """Returns epoch schedule information from this cluster's genesis config.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_epoch_schedule()).value.slots_per_epoch # doctest: +SKIP
        8192
    """
    return await self._provider.make_request(self._get_epoch_schedule, GetEpochScheduleResp)

get_fee_for_message(message, commitment=None) async

Returns the fee for a message.

Parameters:

Name Type Description Default
message MessageV0

Message that the fee is requested for.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

from solders.keypair import Keypair from solders.system_program import TransferParams, transfer from solders.message import MessageV0 leading_zeros = [0] * 31 sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2]) solana_client = AsyncClient("http://localhost:8899") msg = MessageV0.try_compile( # doctest: +SKIP ... payer=sender.pubkey(), ... instructions=[transfer(TransferParams( ... from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))], ... address_lookup_table_accounts=[], ... recent_blockhash=(await solana_client.get_latest_blockhash()).value.blockhash, ... ) (await solana_client.get_fee_for_message(msg)).value # doctest: +SKIP 5000

Source code in src/solana/rpc/async_api.py
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
async def get_fee_for_message(
    self, message: MessageV0, commitment: Commitment | None = None
) -> GetFeeForMessageResp:
    """Returns the fee for a message.

    Args:
        message: Message that the fee is requested for.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> from solders.keypair import Keypair
        >>> from solders.system_program import TransferParams, transfer
        >>> from solders.message import MessageV0
        >>> leading_zeros = [0] * 31
        >>> sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2])
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> msg = MessageV0.try_compile( # doctest: +SKIP
        ...     payer=sender.pubkey(),
        ...     instructions=[transfer(TransferParams(
        ...         from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))],
        ...     address_lookup_table_accounts=[],
        ...     recent_blockhash=(await solana_client.get_latest_blockhash()).value.blockhash,
        ... )
        >>> (await solana_client.get_fee_for_message(msg)).value # doctest: +SKIP
        5000
    """
    body = self._get_fee_for_message_body(message, commitment)
    return await self._provider.make_request(body, GetFeeForMessageResp)

get_first_available_block() async

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

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_first_available_block()).value # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
554
555
556
557
558
559
560
561
562
async def get_first_available_block(self) -> GetFirstAvailableBlockResp:
    """Returns the slot of the lowest confirmed block that has not been purged from the ledger.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_first_available_block()).value # doctest: +SKIP
        1
    """
    return await self._provider.make_request(self._get_first_available_block, GetFirstAvailableBlockResp)

get_genesis_hash() async

Returns the genesis hash.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_genesis_hash()).value # doctest: +SKIP Hash( EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG, )

Source code in src/solana/rpc/async_api.py
564
565
566
567
568
569
570
571
572
573
574
async def get_genesis_hash(self) -> GetGenesisHashResp:
    """Returns the genesis hash.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_genesis_hash()).value # doctest: +SKIP
        Hash(
            EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG,
        )
    """
    return await self._provider.make_request(self._get_genesis_hash, GetGenesisHashResp)

get_identity() async

Returns the identity pubkey for the current node.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_identity()).value.identity # doctest: +SKIP Pubkey( 2LVtX3Wq5bhqAYYaUYBRknWaYrsfYiXLQBHTxtHWD2mv, )

Source code in src/solana/rpc/async_api.py
576
577
578
579
580
581
582
583
584
585
586
async def get_identity(self) -> GetIdentityResp:
    """Returns the identity pubkey for the current node.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_identity()).value.identity # doctest: +SKIP
        Pubkey(
            2LVtX3Wq5bhqAYYaUYBRknWaYrsfYiXLQBHTxtHWD2mv,
        )
    """
    return await self._provider.make_request(self._get_identity, GetIdentityResp)

get_inflation_governor(commitment=None) async

Returns the current inflation governor.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") await (solana_client.get_inflation_governor()).value.foundation # doctest: +SKIP 0.05

Source code in src/solana/rpc/async_api.py
588
589
590
591
592
593
594
595
596
597
598
599
600
async def get_inflation_governor(self, commitment: Commitment | None = None) -> GetInflationGovernorResp:
    """Returns the current inflation governor.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> await (solana_client.get_inflation_governor()).value.foundation # doctest: +SKIP
        0.05
    """
    body = self._get_inflation_governor_body(commitment)
    return await self._provider.make_request(body, GetInflationGovernorResp)

get_inflation_rate() async

Returns the specific inflation values for the current epoch.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_inflation_rate()).value.epoch # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
602
603
604
605
606
607
608
609
610
async def get_inflation_rate(self) -> GetInflationRateResp:
    """Returns the specific inflation values for the current epoch.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_inflation_rate()).value.epoch # doctest: +SKIP
        1
    """
    return await self._provider.make_request(self._get_inflation_rate, GetInflationRateResp)

get_inflation_reward(pubkeys, epoch=None, commitment=None) async

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

Parameters:

Name Type Description Default
pubkeys list[Pubkey]

An array of addresses to query, as base-58 encoded strings

required
epoch int | None

(optional) An epoch for which the reward occurs. If omitted, the previous epoch will be used

None
commitment Commitment | None

Bank state to query. It can be either "finalized" or "confirmed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_inflation_reward()).value.amount # doctest: +SKIP 2500

Source code in src/solana/rpc/async_api.py
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
async def get_inflation_reward(
    self,
    pubkeys: list[Pubkey],
    epoch: int | None = None,
    commitment: Commitment | None = None,
) -> GetInflationRewardResp:
    """Returns the inflation / staking reward for a list of addresses for an epoch.

    Args:
        pubkeys: An array of addresses to query, as base-58 encoded strings
        epoch: (optional) An epoch for which the reward occurs. If omitted, the previous epoch will be used
        commitment: Bank state to query. It can be either "finalized" or "confirmed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_inflation_reward()).value.amount # doctest: +SKIP
        2500
    """
    body = self._get_inflation_reward_body(pubkeys, epoch, commitment)
    return await self._provider.make_request(body, GetInflationRewardResp)

get_largest_accounts(filter_opt=None, commitment=None) async

Returns the 20 largest accounts, by lamport balance.

Parameters:

Name Type Description Default
filter_opt str | None

Filter results by account type; currently supported: circulating|nonCirculating.

None
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_largest_accounts()).value[0].lamports # doctest: +SKIP 500000000000000000

Source code in src/solana/rpc/async_api.py
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
async def get_largest_accounts(
    self, filter_opt: str | None = None, commitment: Commitment | None = None
) -> GetLargestAccountsResp:
    """Returns the 20 largest accounts, by lamport balance.

    Args:
        filter_opt: Filter results by account type; currently supported: circulating|nonCirculating.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_largest_accounts()).value[0].lamports # doctest: +SKIP
        500000000000000000
    """
    body = self._get_largest_accounts_body(filter_opt, commitment)
    return await self._provider.make_request(body, GetLargestAccountsResp)

get_latest_blockhash(commitment=None) async

Returns the latest block hash from the ledger.

Response also includes the last valid block height.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_latest_blockhash()).value # doctest: +SKIP RpcBlockhash { blockhash: Hash( 4TLzN2RAACFnd5TYpHcUi76pC3V1qkggRF29HWk2VLeT, ), last_valid_block_height: 158286487, }

Source code in src/solana/rpc/async_api.py
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
async def get_latest_blockhash(self, commitment: Commitment | None = None) -> GetLatestBlockhashResp:
    """Returns the latest block hash from the ledger.

    Response also includes the last valid block height.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_latest_blockhash()).value # doctest: +SKIP
        RpcBlockhash {
            blockhash: Hash(
                4TLzN2RAACFnd5TYpHcUi76pC3V1qkggRF29HWk2VLeT,
            ),
            last_valid_block_height: 158286487,
        }
    """
    body = self._get_latest_blockhash_body(commitment)
    return await self._provider.make_request(body, GetLatestBlockhashResp)

get_leader_schedule(epoch=None, commitment=None) async

Returns the leader schedule for an epoch.

Parameters:

Name Type Description Default
epoch int | None

Fetch the leader schedule for the epoch that corresponds to the provided slot. If unspecified, the leader schedule for the current epoch is fetched.

None
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") resp = await solana_client.get_leader_schedule() # doctest: +SKIP list(resp.value.items())[0] # doctest: +SKIP (Pubkey( HMU77m6WSL9Xew9YvVCgz1hLuhzamz74eD9avi4XPdr, ), [346448, 346449, 346450, 346451, 369140, 369141, 369142, 369143, 384204, 384205, 384206, 384207])

Source code in src/solana/rpc/async_api.py
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
async def get_leader_schedule(
    self, epoch: int | None = None, commitment: Commitment | None = None
) -> GetLeaderScheduleResp:
    """Returns the leader schedule for an epoch.

    Args:
        epoch: Fetch the leader schedule for the epoch that corresponds to the provided slot.
            If unspecified, the leader schedule for the current epoch is fetched.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> resp = await solana_client.get_leader_schedule() # doctest: +SKIP
        >>> list(resp.value.items())[0] # doctest: +SKIP
        (Pubkey(
            HMU77m6WSL9Xew9YvVCgz1hLuhzamz74eD9avi4XPdr,
        ), [346448, 346449, 346450, 346451, 369140, 369141, 369142, 369143, 384204, 384205, 384206, 384207])
    """
    body = self._get_leader_schedule_body(epoch, commitment)
    return await self._provider.make_request(body, GetLeaderScheduleResp)

get_minimum_balance_for_rent_exemption(usize, commitment=None) async

Returns minimum balance required to make account rent exempt.

Parameters:

Name Type Description Default
usize int

Account data length.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_minimum_balance_for_rent_exemption(50)).value # doctest: +SKIP 1238880

Source code in src/solana/rpc/async_api.py
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
async def get_minimum_balance_for_rent_exemption(
    self, usize: int, commitment: Commitment | None = None
) -> GetMinimumBalanceForRentExemptionResp:
    """Returns minimum balance required to make account rent exempt.

    Args:
        usize: Account data length.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_minimum_balance_for_rent_exemption(50)).value # doctest: +SKIP
        1238880
    """
    body = self._get_minimum_balance_for_rent_exemption_body(usize, commitment)
    return await self._provider.make_request(body, GetMinimumBalanceForRentExemptionResp)

get_minimum_ledger_slot() async

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.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_minimum_ledger_slot()).value # doctest: +SKIP 1234

Source code in src/solana/rpc/async_api.py
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
async def get_minimum_ledger_slot(self) -> MinimumLedgerSlotResp:
    """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.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_minimum_ledger_slot()).value # doctest: +SKIP
        1234
    """
    return await self._provider.make_request(self._minimum_ledger_slot, MinimumLedgerSlotResp)

get_multiple_accounts(pubkeys, commitment=None, encoding='base64', data_slice=None) async

Returns all the account info for a list of public keys.

Parameters:

Name Type Description Default
pubkeys list[Pubkey]

list of Pubkeys to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
encoding str

(optional) Encoding for Account data, either "base58" (slow) or "base64".

  • "base58" is limited to Account data of less than 128 bytes.
  • "base64" will return base64 encoded data for Account data of any size.
'base64'
data_slice DataSliceOpts | None

(optional) Option to limit the returned account data using the provided offset: and length: fields; only available for "base58" or "base64" encoding.

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")] (await solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
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
715
716
717
718
719
720
721
async def get_multiple_accounts(
    self,
    pubkeys: list[Pubkey],
    commitment: Commitment | None = None,
    encoding: str = "base64",
    data_slice: DataSliceOptsModel | None = None,
) -> GetMultipleAccountsResp:
    """Returns all the account info for a list of public keys.

    Args:
        pubkeys: list of Pubkeys to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        encoding: (optional) Encoding for Account data, either "base58" (slow) or "base64".

            - "base58" is limited to Account data of less than 128 bytes.
            - "base64" will return base64 encoded data for Account data of any size.

        data_slice: (optional) Option to limit the returned account data using the provided `offset`: <usize> and
            `length`: <usize> fields; only available for "base58" or "base64" encoding.

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")]
        >>> (await solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP
        1
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_multiple_accounts_body(
        pubkeys=pubkeys,
        commitment=commitment,
        encoding=encoding,
        data_slice=data_slice,
    )
    return await self._provider.make_request(body, GetMultipleAccountsResp)

get_multiple_accounts_json_parsed(pubkeys, commitment=None) async

Returns all the account info for a list of public keys.

Parameters:

Name Type Description Default
pubkeys list[Pubkey]

list of Pubkeys to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")] asyncio.run(solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
async def get_multiple_accounts_json_parsed(
    self,
    pubkeys: list[Pubkey],
    commitment: Commitment | None = None,
) -> GetMultipleAccountsMaybeJsonParsedResp:
    """Returns all the account info for a list of public keys.

    Args:
        pubkeys: list of Pubkeys to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> pubkeys = [Pubkey.from_string("6ZWcsUiWJ63awprYmbZgBQSreqYZ4s6opowP4b7boUdh"), Pubkey.from_string("HkcE9sqQAnjJtECiFsqGMNmUho3ptXkapUPAqgZQbBSY")]
        >>> asyncio.run(solana_client.get_multiple_accounts(pubkeys)).value[0].lamports # doctest: +SKIP
        1
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_multiple_accounts_body(
        pubkeys=pubkeys,
        commitment=commitment,
        encoding="jsonParsed",
        data_slice=None,
    )
    return await self._provider.make_request(body, GetMultipleAccountsMaybeJsonParsedResp)

get_program_accounts(pubkey, commitment=None, encoding=None, data_slice=None, filters=None) async

Returns all accounts owned by the provided program Pubkey.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of program

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
encoding str | None

(optional) Encoding for the returned Transaction, either jsonParsed", "base58" (slow), or "base64".

None
data_slice DataSliceOpts | None

(optional) Limit the returned account data using the provided offset: and length: fields; only available for "base58" or "base64" encoding.

None
filters Sequence[int | MemcmpOpts] | None

(optional) Options to compare a provided series of bytes with program account data at a particular offset. Note: an int entry is converted to a dataSize filter.

None
Example

from solana.rpc.models import MemcmpOpts solana_client = AsyncClient("http://localhost:8899") memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR") pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T") filters: list[int | MemcmpOpts] = [17, memcmp_opts] (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
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
774
775
776
777
778
779
780
781
782
783
784
785
async def get_program_accounts(  # pylint: disable=too-many-arguments
    self,
    pubkey: Pubkey,
    commitment: Commitment | None = None,
    encoding: str | None = None,
    data_slice: DataSliceOptsModel | None = None,
    filters: Sequence[int | MemcmpOptsModel] | None = None,
) -> GetProgramAccountsResp:
    """Returns all accounts owned by the provided program Pubkey.

    Args:
        pubkey: Pubkey of program
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        encoding: (optional) Encoding for the returned Transaction, either jsonParsed",
            "base58" (slow), or "base64".
        data_slice: (optional) Limit the returned account data using the provided `offset`: <usize> and
            `length`: <usize> fields; only available for "base58" or "base64" encoding.
        filters: (optional) Options to compare a provided series of bytes with program account data at a particular offset.
            Note: an int entry is converted to a `dataSize` filter.

    Example:
        >>> from solana.rpc.models import MemcmpOpts
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR")
        >>> pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T")
        >>> filters: list[int | MemcmpOpts] = [17, memcmp_opts]
        >>> (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP
        1
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_program_accounts_body(
        pubkey=pubkey,
        commitment=commitment,
        encoding=encoding,
        data_slice=data_slice,
        filters=filters,
    )
    return await self._provider.make_request(body, GetProgramAccountsResp)

get_program_accounts_json_parsed(pubkey, commitment=None, filters=None) async

Returns all accounts owned by the provided program Pubkey.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of program

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
filters Sequence[int | MemcmpOpts] | None

(optional) Options to compare a provided series of bytes with program account data at a particular offset. Note: an int entry is converted to a dataSize filter.

None
Example

from solana.rpc.models import MemcmpOpts solana_client = AsyncClient("http://localhost:8899") memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR") pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T") filters: list[int | MemcmpOpts] = [17, memcmp_opts] (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP 1

Source code in src/solana/rpc/async_api.py
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
async def get_program_accounts_json_parsed(  # pylint: disable=too-many-arguments
    self,
    pubkey: Pubkey,
    commitment: Commitment | None = None,
    filters: Sequence[int | MemcmpOptsModel] | None = None,
) -> GetProgramAccountsMaybeJsonParsedResp:
    """Returns all accounts owned by the provided program Pubkey.

    Args:
        pubkey: Pubkey of program
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        filters: (optional) Options to compare a provided series of bytes with program account data at a particular offset.
            Note: an int entry is converted to a `dataSize` filter.

    Example:
        >>> from solana.rpc.models import MemcmpOpts
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> memcmp_opts = MemcmpOpts(offset=4, bytes="3Mc6vR")
        >>> pubkey = Pubkey.from_string("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T")
        >>> filters: list[int | MemcmpOpts] = [17, memcmp_opts]
        >>> (await solana_client.get_program_accounts(pubkey, filters=filters)).value[0].account.lamports # doctest: +SKIP
        1
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_program_accounts_body(
        pubkey=pubkey,
        commitment=commitment,
        encoding="jsonParsed",
        data_slice=None,
        filters=filters,
    )
    return await self._provider.make_request(body, GetProgramAccountsMaybeJsonParsedResp)

get_recent_performance_samples(limit=None) async

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:

Name Type Description Default
limit int | None

Limit (optional) number of samples to return (maximum 720)

None

Examples:

>>> solana_client = AsyncClient("http://localhost:8899")
>>> (await solana_client.get_recent_performance_samples(1)).value[0]
RpcPerfSample(
    RpcPerfSample {
        slot: 168036172,
        num_transactions: 7159,
        num_slots: 158,
        sample_period_secs: 60,
    },
)
Source code in src/solana/rpc/async_api.py
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
async def get_recent_performance_samples(self, limit: int | None = None) -> GetRecentPerformanceSamplesResp:
    """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.

    Args:
        limit: Limit (optional) number of samples to return (maximum 720)

    Examples:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_recent_performance_samples(1)).value[0] # doctest: +SKIP
        RpcPerfSample(
            RpcPerfSample {
                slot: 168036172,
                num_transactions: 7159,
                num_slots: 158,
                sample_period_secs: 60,
            },
        )
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_recent_performance_samples_body(limit)
    return await self._provider.make_request(body, GetRecentPerformanceSamplesResp)

get_recent_prioritization_fees(addresses=None) async

Returns a list of recent prioritization fees, in reverse slot order.

Parameters:

Name Type Description Default
addresses Sequence[Pubkey] | None

Account addresses to query. If omitted, the response includes recent prioritization fees from the node's recent blocks.

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_recent_prioritization_fees()).value[0] # doctest: +SKIP RpcPrioritizationFee( RpcPrioritizationFee { slot: 348125, prioritization_fee: 1000, }, )

Source code in src/solana/rpc/async_api.py
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
async def get_recent_prioritization_fees(
    self, addresses: Sequence[Pubkey] | None = None
) -> GetRecentPrioritizationFeesResp:
    """Returns a list of recent prioritization fees, in reverse slot order.

    Args:
        addresses: Account addresses to query. If omitted, the response includes recent prioritization fees
            from the node's recent blocks.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_recent_prioritization_fees()).value[0] # doctest: +SKIP
        RpcPrioritizationFee(
            RpcPrioritizationFee {
                slot: 348125,
                prioritization_fee: 1000,
            },
        )
    """
    body = GetRecentPrioritizationFees(addresses)
    return await self._provider.make_request(body, GetRecentPrioritizationFeesResp)

get_signature_statuses(signatures, search_transaction_history=False) async

Returns the statuses of a list of signatures.

Unless the search_transaction_history 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:

Name Type Description Default
signatures list[Signature]

An array of transaction signatures to confirm.

required
search_transaction_history bool

If true, a Solana node will search its ledger cache for any signatures not found in the recent status cache.

False
Example

solana_client = AsyncClient("http://localhost:8899") raw_sigs = [ ... "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW", ... "5j7s6NiJS3JAkvgkoc18WVAsiSaci2pxB2A6ueCJP4tprA2TFg9wSyTLeYouxPBJEMzJinENTkpA52YStRW5Dia7"] sigs = [Signature.from_string(sig) for sig in raw_sigs] (await solana_client.get_signature_statuses(sigs)).value[0].confirmations # doctest: +SKIP 10

Source code in src/solana/rpc/async_api.py
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
async def get_signature_statuses(
    self, signatures: list[Signature], search_transaction_history: bool = False
) -> GetSignatureStatusesResp:
    """Returns the statuses of a list of signatures.

    Unless the `search_transaction_history` 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.

    Args:
        signatures: An array of transaction signatures to confirm.
        search_transaction_history: If true, a Solana node will search its ledger cache for
            any signatures not found in the recent status cache.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> raw_sigs = [
        ...     "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
        ...     "5j7s6NiJS3JAkvgkoc18WVAsiSaci2pxB2A6ueCJP4tprA2TFg9wSyTLeYouxPBJEMzJinENTkpA52YStRW5Dia7"]
        >>> sigs = [Signature.from_string(sig) for sig in raw_sigs]
        >>> (await solana_client.get_signature_statuses(sigs)).value[0].confirmations # doctest: +SKIP
        10
    """
    body = self._get_signature_statuses_body(signatures, search_transaction_history)
    return await self._provider.make_request(body, GetSignatureStatusesResp)

get_signatures_for_address(account, before=None, until=None, limit=None, commitment=None, min_context_slot=None) async

Returns confirmed signatures for transactions involving an address.

Signatures are returned backwards in time from the provided signature or most recent confirmed block.

Parameters:

Name Type Description Default
account Pubkey

Account to be queried.

required
before Signature | None

(optional) Start searching backwards from this transaction signature. If not provided the search starts from the top of the highest max confirmed block.

None
until Signature | None

(optional) Search until this transaction signature, if found before limit reached.

None
limit int | None

(optional) Maximum transaction signatures to return (between 1 and 1,000, default: 1,000).

None
commitment Commitment | None

(optional) Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
min_context_slot int | None

(optional) The minimum slot that the request can be evaluated at.

None
Example

solana_client = AsyncClient("http://localhost:8899") from solders.pubkey import Pubkey pubkey = Pubkey.from_string("Vote111111111111111111111111111111111111111") (await solana_client.get_signatures_for_address(pubkey, limit=1)).value[0].signature # doctest: +SKIP Signature( 1111111111111111111111111111111111111111111111111111111111111111, )

Source code in src/solana/rpc/async_api.py
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
async def get_signatures_for_address(
    self,
    account: Pubkey,
    before: Signature | None = None,
    until: Signature | None = None,
    limit: int | None = None,
    commitment: Commitment | None = None,
    min_context_slot: int | None = None,
) -> GetSignaturesForAddressResp:
    """Returns confirmed signatures for transactions involving an address.

    Signatures are returned backwards in time from the provided signature or
    most recent confirmed block.

    Args:
        account: Account to be queried.
        before: (optional) Start searching backwards from this transaction signature.
            If not provided the search starts from the top of the highest max confirmed block.
        until: (optional) Search until this transaction signature, if found before limit reached.
        limit: (optional) Maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
        commitment: (optional) Bank state to query. It can be either "finalized", "confirmed" or "processed".
        min_context_slot: (optional) The minimum slot that the request can be evaluated at.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> from solders.pubkey import Pubkey
        >>> pubkey = Pubkey.from_string("Vote111111111111111111111111111111111111111")
        >>> (await solana_client.get_signatures_for_address(pubkey, limit=1)).value[0].signature # doctest: +SKIP
        Signature(
            1111111111111111111111111111111111111111111111111111111111111111,
        )
    """
    body = self._get_signatures_for_address_body(account, before, until, limit, commitment, min_context_slot)
    return await self._provider.make_request(body, GetSignaturesForAddressResp)

get_slot(commitment=None) async

Returns the current slot the node is processing.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_slot()).value # doctest: +SKIP 7515

Source code in src/solana/rpc/async_api.py
866
867
868
869
870
871
872
873
874
875
876
877
878
async def get_slot(self, commitment: Commitment | None = None) -> GetSlotResp:
    """Returns the current slot the node is processing.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_slot()).value # doctest: +SKIP
        7515
    """
    body = self._get_slot_body(commitment)
    return await self._provider.make_request(body, GetSlotResp)

get_slot_leader(commitment=None) async

Returns the current slot leader.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_slot_leader()).value # doctest: +SKIP Pubkey( dv2eQHeP4RFrJZ6UeiZWoc3XTtmtZCUKxxCApCDcRNV, )

Source code in src/solana/rpc/async_api.py
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
async def get_slot_leader(self, commitment: Commitment | None = None) -> GetSlotLeaderResp:
    """Returns the current slot leader.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_slot_leader()).value # doctest: +SKIP
        Pubkey(
            dv2eQHeP4RFrJZ6UeiZWoc3XTtmtZCUKxxCApCDcRNV,
        )
    """
    body = self._get_slot_leader_body(commitment)
    return await self._provider.make_request(body, GetSlotLeaderResp)

get_slot_leaders(start, limit) async

Returns the list of slot leaders for the provided start slot and limit.

Parameters:

Name Type Description Default
start int

The start slot to get the slot leaders from.

required
limit int

The number of slot leaders to return.

required

Returns:

Type Description
GetSlotLeadersResp

A list of slot leaders.

Source code in src/solana/rpc/async_api.py
896
897
898
899
900
901
902
903
904
905
906
907
async def get_slot_leaders(self, start: int, limit: int) -> GetSlotLeadersResp:
    """Returns the list of slot leaders for the provided start slot and limit.

    Args:
        start: The start slot to get the slot leaders from.
        limit: The number of slot leaders to return.

    Returns:
        A list of slot leaders.
    """
    body = self._get_slot_leaders_body(start, limit)
    return await self._provider.make_request(body, GetSlotLeadersResp)

get_supply(commitment=None, exclude_non_circulating_accounts_list=False) async

Returns information about the current supply.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
exclude_non_circulating_accounts_list bool

If True, exclude non-circulating accounts from supply.

False
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_supply()).value.circulating # doctest: +SKIP 683635192454157660

Source code in src/solana/rpc/async_api.py
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
async def get_supply(
    self,
    commitment: Commitment | None = None,
    exclude_non_circulating_accounts_list: bool = False,
) -> GetSupplyResp:
    """Returns information about the current supply.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        exclude_non_circulating_accounts_list: If True, exclude non-circulating accounts from supply.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_supply()).value.circulating # doctest: +SKIP
        683635192454157660
    """
    body = self._get_supply_body(commitment, exclude_non_circulating_accounts_list)
    return await self._provider.make_request(body, GetSupplyResp)

get_token_account_balance(pubkey, commitment=None) async

Returns the token balance of an SPL Token account (UNSTABLE).

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of Token account to query

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") pubkey = Pubkey.from_string("7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7") (await solana_client.get_token_account_balance(pubkey)).value.amount # noqa: E501 # doctest: +SKIP '9864'

Source code in src/solana/rpc/async_api.py
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
async def get_token_account_balance(
    self, pubkey: Pubkey, commitment: Commitment | None = None
) -> GetTokenAccountBalanceResp:
    """Returns the token balance of an SPL Token account (UNSTABLE).

    Args:
        pubkey: Pubkey of Token account to query
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> pubkey = Pubkey.from_string("7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7")
        >>> (await solana_client.get_token_account_balance(pubkey)).value.amount  # noqa: E501 # doctest: +SKIP
        '9864'
    """
    body = self._get_token_account_balance_body(pubkey, commitment)
    return await self._provider.make_request(body, GetTokenAccountBalanceResp)

get_token_accounts_by_delegate(delegate, opts, commitment=None) async

Returns all SPL Token accounts by approved Delegate (UNSTABLE).

Parameters:

Name Type Description Default
delegate Pubkey

Public key of the delegate owner to query.

required
opts TokenAccountOpts

Token account option specifying at least one of mint or program_id.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Source code in src/solana/rpc/async_api.py
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
async def get_token_accounts_by_delegate(
    self,
    delegate: Pubkey,
    opts: TokenAccountOptsModel,
    commitment: Commitment | None = None,
) -> GetTokenAccountsByDelegateResp:
    """Returns all SPL Token accounts by approved Delegate (UNSTABLE).

    Args:
        delegate: Public key of the delegate owner to query.
        opts: Token account option specifying at least one of `mint` or `program_id`.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
    """
    body = self._get_token_accounts_by_delegate_body(delegate, opts, commitment)
    return await self._provider.make_request(body, GetTokenAccountsByDelegateResp)

get_token_accounts_by_delegate_json_parsed(delegate, opts, commitment=None) async

Returns all SPL Token accounts by approved delegate in JSON format (UNSTABLE).

Parameters:

Name Type Description Default
delegate Pubkey

Public key of the delegate owner to query.

required
opts TokenAccountOpts

Token account option specifying at least one of mint or program_id.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Source code in src/solana/rpc/async_api.py
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
async def get_token_accounts_by_delegate_json_parsed(
    self,
    delegate: Pubkey,
    opts: TokenAccountOptsModel,
    commitment: Commitment | None = None,
) -> GetTokenAccountsByDelegateJsonParsedResp:
    """Returns all SPL Token accounts by approved delegate in JSON format (UNSTABLE).

    Args:
        delegate: Public key of the delegate owner to query.
        opts: Token account option specifying at least one of `mint` or `program_id`.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
    """
    body = self._get_token_accounts_by_delegate_json_parsed_body(delegate, opts, commitment)
    return await self._provider.make_request(body, GetTokenAccountsByDelegateJsonParsedResp)

get_token_accounts_by_owner(owner, opts, commitment=None) async

Returns all SPL Token accounts by token owner (UNSTABLE).

Parameters:

Name Type Description Default
owner Pubkey

Public key of the account owner to query.

required
opts TokenAccountOpts

Token account option specifying at least one of mint or program_id.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Source code in src/solana/rpc/async_api.py
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
async def get_token_accounts_by_owner(
    self,
    owner: Pubkey,
    opts: TokenAccountOptsModel,
    commitment: Commitment | None = None,
) -> GetTokenAccountsByOwnerResp:
    """Returns all SPL Token accounts by token owner (UNSTABLE).

    Args:
        owner: Public key of the account owner to query.
        opts: Token account option specifying at least one of `mint` or `program_id`.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
    """
    body = self._get_token_accounts_by_owner_body(owner, opts, commitment)
    return await self._provider.make_request(body, GetTokenAccountsByOwnerResp)

get_token_accounts_by_owner_json_parsed(owner, opts, commitment=None) async

Returns all SPL Token accounts by token owner in JSON format (UNSTABLE).

Parameters:

Name Type Description Default
owner Pubkey

Public key of the account owner to query.

required
opts TokenAccountOpts

Token account option specifying at least one of mint or program_id.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Source code in src/solana/rpc/async_api.py
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
async def get_token_accounts_by_owner_json_parsed(
    self,
    owner: Pubkey,
    opts: TokenAccountOptsModel,
    commitment: Commitment | None = None,
) -> GetTokenAccountsByOwnerJsonParsedResp:
    """Returns all SPL Token accounts by token owner in JSON format (UNSTABLE).

    Args:
        owner: Public key of the account owner to query.
        opts: Token account option specifying at least one of `mint` or `program_id`.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
    """
    body = self._get_token_accounts_by_owner_json_parsed_body(owner, opts, commitment)
    return await self._provider.make_request(body, GetTokenAccountsByOwnerJsonParsedResp)

get_token_largest_accounts(pubkey, commitment=None) async

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

Source code in src/solana/rpc/async_api.py
1010
1011
1012
1013
1014
1015
async def get_token_largest_accounts(
    self, pubkey: Pubkey, commitment: Commitment | None = None
) -> GetTokenLargestAccountsResp:
    """Returns the 20 largest accounts of a particular SPL Token type."""
    body = self._get_token_largest_accounts_body(pubkey, commitment)
    return await self._provider.make_request(body, GetTokenLargestAccountsResp)

get_token_supply(pubkey, commitment=None) async

Returns the total supply of an SPL Token type.

Source code in src/solana/rpc/async_api.py
1017
1018
1019
1020
async def get_token_supply(self, pubkey: Pubkey, commitment: Commitment | None = None) -> GetTokenSupplyResp:
    """Returns the total supply of an SPL Token type."""
    body = self._get_token_supply_body(pubkey, commitment)
    return await self._provider.make_request(body, GetTokenSupplyResp)

get_transaction(tx_sig, encoding='json', commitment=None, max_supported_transaction_version=None) async

Returns transaction details for a confirmed transaction.

Parameters:

Name Type Description Default
tx_sig Signature

Transaction signature as base-58 encoded string N encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the transaction.message.instructions list.

required
encoding str

(optional) Encoding for the returned Transaction, either "json", "jsonParsed", "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.

'json'
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
max_supported_transaction_version int | None

(optional) The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned

None
Example

solana_client = AsyncClient("http://localhost:8899") from solders.signature import Signature sig = Signature.from_string("3PtGYH77LhhQqTXP4SmDVJ85hmDieWsgXCUbn14v7gYyVYPjZzygUQhTk3bSTYnfA48vCM1rmWY7zWL3j1EVKmEy") (await solana_client.get_transaction(sig)).value.block_time # doctest: +SKIP 1234

Source code in src/solana/rpc/async_api.py
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
async def get_transaction(
    self,
    tx_sig: Signature,
    encoding: str = "json",
    commitment: Commitment | None = None,
    max_supported_transaction_version: int | None = None,
) -> GetTransactionResp:
    """Returns transaction details for a confirmed transaction.

    Args:
        tx_sig: Transaction signature as base-58 encoded string N encoding attempts to use program-specific
            instruction parsers to return more human-readable and explicit data in the
            `transaction.message.instructions` list.
        encoding: (optional) Encoding for the returned Transaction, either "json", "jsonParsed",
            "base58" (slow), or "base64". If parameter not provided, the default encoding is JSON.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        max_supported_transaction_version: (optional) The max transaction version to return in responses.
            If the requested transaction is a higher version, an error will be returned

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> from solders.signature import Signature
        >>> sig = Signature.from_string("3PtGYH77LhhQqTXP4SmDVJ85hmDieWsgXCUbn14v7gYyVYPjZzygUQhTk3bSTYnfA48vCM1rmWY7zWL3j1EVKmEy")
        >>> (await solana_client.get_transaction(sig)).value.block_time # doctest: +SKIP
        1234
    """  # noqa: E501 # pylint: disable=line-too-long
    body = self._get_transaction_body(tx_sig, encoding, commitment, max_supported_transaction_version)
    return await self._provider.make_request(body, GetTransactionResp)

get_transaction_count(commitment=None) async

Returns the current Transaction count from the ledger.

Parameters:

Name Type Description Default
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_transaction_count()).value # doctest: +SKIP 4554

Source code in src/solana/rpc/async_api.py
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
async def get_transaction_count(self, commitment: Commitment | None = None) -> GetTransactionCountResp:
    """Returns the current Transaction count from the ledger.

    Args:
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_transaction_count()).value # doctest: +SKIP
        4554
    """
    body = self._get_transaction_count_body(commitment)
    return await self._provider.make_request(body, GetTransactionCountResp)

get_version() async

Returns the current solana versions running on the node.

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_version()).value.solana_core # doctest: +SKIP '1.13.2'

Source code in src/solana/rpc/async_api.py
1048
1049
1050
1051
1052
1053
1054
1055
1056
async def get_version(self) -> GetVersionResp:
    """Returns the current solana versions running on the node.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_version()).value.solana_core # doctest: +SKIP
        '1.13.2'
    """
    return await self._provider.make_request(self._get_version, GetVersionResp)

get_vote_accounts(vote_pubkey=None, commitment=None, keep_unstaked_delinquents=None, delinquent_slot_distance=None) async

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

Parameters:

Name Type Description Default
vote_pubkey Pubkey | None

Only return results for this validator vote address.

None
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
keep_unstaked_delinquents bool | None

Filter out delinquent validators with no stake.

None
delinquent_slot_distance int | None

Specify the number of slots behind the tip that the validator must fall to be considered delinquent.

None
Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.get_vote_accounts()).value.current[0].commission # doctest: +SKIP 100

Source code in src/solana/rpc/async_api.py
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
async def get_vote_accounts(
    self,
    vote_pubkey: Pubkey | None = None,
    commitment: Commitment | None = None,
    keep_unstaked_delinquents: bool | None = None,
    delinquent_slot_distance: int | None = None,
) -> GetVoteAccountsResp:
    """Returns the account info and associated stake for all the voting accounts in the current bank.

    Args:
        vote_pubkey: Only return results for this validator vote address.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        keep_unstaked_delinquents: Filter out delinquent validators with no stake.
        delinquent_slot_distance: Specify the number of slots behind the tip that the validator must fall
            to be considered delinquent.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.get_vote_accounts()).value.current[0].commission # doctest: +SKIP
        100
    """
    body = self._get_vote_accounts_body(
        vote_pubkey, commitment, keep_unstaked_delinquents, delinquent_slot_distance
    )
    return await self._provider.make_request(body, GetVoteAccountsResp)

is_connected() async

Health check.

solana_client = AsyncClient("http://localhost:8899") asyncio.run(solana_client.is_connected()) # doctest: +SKIP True

Returns:

Type Description
bool

True if the client is connected.

Source code in src/solana/rpc/async_api.py
187
188
189
190
191
192
193
194
195
196
197
198
199
async def is_connected(self) -> bool:
    """Health check.

    >>> solana_client = AsyncClient("http://localhost:8899")
    >>> asyncio.run(solana_client.is_connected()) # doctest: +SKIP
    True

    Returns:
        True if the client is connected.
    """
    body = self._get_health_body()
    response = await self._provider.make_request(body, GetHealthResp)
    return response.value == "ok"

request_airdrop(pubkey, lamports, commitment=None) async

Requests an airdrop of lamports to a Pubkey.

Parameters:

Name Type Description Default
pubkey Pubkey

Pubkey of account to receive lamports, as base-58 encoded string or public key object.

required
lamports int

Amount of lamports.

required
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
Example

from solders.pubkey import Pubkey solana_client = AsyncClient("http://localhost:8899") (await solana_client.request_airdrop(Pubkey([0] * 31 + [1]), 10000)).value # doctest: +SKIP Signature( 1111111111111111111111111111111111111111111111111111111111111111, )

Source code in src/solana/rpc/async_api.py
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
async def request_airdrop(
    self, pubkey: Pubkey, lamports: int, commitment: Commitment | None = None
) -> RequestAirdropResp:
    """Requests an airdrop of lamports to a Pubkey.

    Args:
        pubkey: Pubkey of account to receive lamports, as base-58 encoded string or public key object.
        lamports: Amount of lamports.
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".

    Example:
        >>> from solders.pubkey import Pubkey
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.request_airdrop(Pubkey([0] * 31 + [1]), 10000)).value # doctest: +SKIP
        Signature(
            1111111111111111111111111111111111111111111111111111111111111111,
        )
    """
    body = self._request_airdrop_body(pubkey, lamports, commitment)
    return await self._provider.make_request(body, RequestAirdropResp)

send_raw_transaction(txn, opts=None) async

Send a transaction that has already been signed and serialized into the wire format.

Parameters:

Name Type Description Default
txn bytes

Transaction bytes.

required
opts TxOpts | None

(optional) Transaction options.

None

Before submitting, the following preflight checks are performed (unless disabled with the skip_preflight option):

- The transaction signatures are verified.

- The transaction is simulated against the latest max confirmed bank and on failure an error
    will be returned. Preflight checks may be disabled if desired.
Example

solana_client = AsyncClient("http://localhost:8899") full_signed_tx_hex = ( ... '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc' ... '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41' ... '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000' ... '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7' ... '1851a106901020200010c0200000040420f0000000000' ... ) (await solana_client.send_raw_transaction(bytes.fromhex(full_signed_tx_hex))).value # doctest: +SKIP Signature( 1111111111111111111111111111111111111111111111111111111111111111, )

Source code in src/solana/rpc/async_api.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
async def send_raw_transaction(self, txn: bytes, opts: TxOptsModel | None = None) -> SendTransactionResp:
    """Send a transaction that has already been signed and serialized into the wire format.

    Args:
        txn: Transaction bytes.
        opts: (optional) Transaction options.

    Before submitting, the following preflight checks are performed (unless disabled with the `skip_preflight` option):

        - The transaction signatures are verified.

        - The transaction is simulated against the latest max confirmed bank and on failure an error
            will be returned. Preflight checks may be disabled if desired.


    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> full_signed_tx_hex = (
        ...     '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc'
        ...     '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41'
        ...     '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000'
        ...     '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7'
        ...     '1851a106901020200010c0200000040420f0000000000'
        ... )
        >>> (await solana_client.send_raw_transaction(bytes.fromhex(full_signed_tx_hex))).value  # doctest: +SKIP
        Signature(
            1111111111111111111111111111111111111111111111111111111111111111,
        )
    """  # noqa: E501 # pylint: disable=line-too-long
    opts_to_use = TxOptsModel(preflight_commitment=self._commitment) if opts is None else opts
    body = self._send_raw_transaction_body(txn, opts_to_use)

    resp = await self._provider.make_request(body, SendTransactionResp)
    if opts_to_use.skip_confirmation:
        return self._post_send(resp)
    post_send_args = self._send_raw_transaction_post_send_args(resp, opts_to_use)
    return await self.__post_send_with_confirm(*post_send_args)

send_rpc_request(request, result_type, *, error_parser=None) async

send_rpc_request(
    request: JsonRpcRequest,
    result_type: type[TResult],
    *,
    error_parser: JsonRpcErrorParser | None = None,
) -> TResult
send_rpc_request(
    request: JsonRpcRequest,
    result_type: Any,
    *,
    error_parser: JsonRpcErrorParser | None = None,
) -> Any

Send a raw JSON-RPC request and parse the result with the provided type.

Source code in src/solana/rpc/async_api.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
async def send_rpc_request(
    self,
    request: JsonRpcRequest,
    result_type: Any,
    *,
    error_parser: JsonRpcErrorParser | None = None,
) -> Any:
    """Send a raw JSON-RPC request and parse the result with the provided type."""
    if not isinstance(request, JsonRpcRequest):
        raise TypeError("request must be an instance of JsonRpcRequest")
    raw = await self._provider.make_request_unparsed(request)
    envelope = JsonRpcResponseEnvelope.model_validate_json(raw)
    result = envelope.unwrap_result(error_parser, method=getattr(request, "method", None))
    return TypeAdapter(result_type).validate_python(result)

send_transaction(txn, opts=None) async

Send a transaction.

Parameters:

Name Type Description Default
txn VersionedTransaction

transaction object.

required
opts TxOpts | None

(optional) Transaction options.

None
Example

from solders.keypair import Keypair from solders.system_program import TransferParams, transfer from solders.message import MessageV0 from solders.transaction import VersionedTransaction leading_zeros = [0] * 31 sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2]) ixns = [transfer(TransferParams( ... from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))] client = AsyncClient("http://localhost:8899") msg = MessageV0.try_compile( # doctest: +SKIP ... payer=sender.pubkey(), ... instructions=ixns, ... address_lookup_table_accounts=[], ... recent_blockhash=(await client.get_latest_blockhash()).value.blockhash, ... ) (await client.send_transaction(VersionedTransaction(msg, [sender]))) # doctest: +SKIP

Source code in src/solana/rpc/async_api.py
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
async def send_transaction(
    self,
    txn: VersionedTransaction,
    opts: TxOptsModel | None = None,
) -> SendTransactionResp:
    """Send a transaction.

    Args:
        txn: transaction object.
        opts: (optional) Transaction options.

    Example:
        >>> from solders.keypair import Keypair
        >>> from solders.system_program import TransferParams, transfer
        >>> from solders.message import MessageV0
        >>> from solders.transaction import VersionedTransaction
        >>> leading_zeros = [0] * 31
        >>> sender, receiver = Keypair.from_seed(leading_zeros + [1]), Keypair.from_seed(leading_zeros + [2])
        >>> ixns = [transfer(TransferParams(
        ...     from_pubkey=sender.pubkey(), to_pubkey=receiver.pubkey(), lamports=1000))]
        >>> client = AsyncClient("http://localhost:8899")
        >>> msg = MessageV0.try_compile( # doctest: +SKIP
        ...     payer=sender.pubkey(),
        ...     instructions=ixns,
        ...     address_lookup_table_accounts=[],
        ...     recent_blockhash=(await client.get_latest_blockhash()).value.blockhash,
        ... )
        >>> (await client.send_transaction(VersionedTransaction(msg, [sender]))) # doctest: +SKIP
    """
    return await self.send_raw_transaction(bytes(txn), opts=opts)

simulate_transaction(txn, sig_verify=False, commitment=None, replace_recent_blockhash=False, min_context_slot=None, inner_instructions=False, accounts_addresses=None, accounts_encoding='base64') async

Simulate sending a transaction.

Parameters:

Name Type Description Default
txn VersionedTransaction

A transaction object.

required
sig_verify bool

If True the transaction signatures will be verified (conflicts with replace_recent_blockhash).

False
commitment Commitment | None

Bank state to query. It can be either "finalized", "confirmed" or "processed".

None
replace_recent_blockhash bool

If True the transaction recent blockhash will be replaced with the most recent blockhash (conflicts with sig_verify).

False
min_context_slot int | None

The minimum slot that the request can be evaluated at.

None
inner_instructions bool

If true the response will include inner instructions. These inner instructions will be jsonParsed where possible, otherwise json.

False
accounts_addresses list[Pubkey] | None

An array of accounts to return, as base-58 encoded strings

None
accounts_encoding str

Encoding for returned Account data. Note: jsonParsed encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the returned accounts field is type string.

'base64'
Example

solana_client = AsyncClient("http://localhost:8899") full_signed_tx_hex = ( ... '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc' ... '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41' ... '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000' ... '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7' ... '1851a106901020200010c0200000040420f0000000000' ... ) tx = VersionedTransaction.from_bytes(bytes.fromhex(full_signed_tx_hex)) (await solana_client.simulate_transaction(tx)).value.logs # doctest: +SKIP ['BPF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success']

Source code in src/solana/rpc/async_api.py
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
async def simulate_transaction(
    self,
    txn: VersionedTransaction,
    sig_verify: bool = False,
    commitment: Commitment | None = None,
    replace_recent_blockhash: bool = False,
    min_context_slot: int | None = None,
    inner_instructions: bool = False,
    accounts_addresses: list[Pubkey] | None = None,
    accounts_encoding: str = "base64",
) -> SimulateTransactionResp:
    """Simulate sending a transaction.

    Args:
        txn: A transaction object.
        sig_verify: If True the transaction signatures will be verified
            (conflicts with ``replace_recent_blockhash``).
        commitment: Bank state to query. It can be either "finalized", "confirmed" or "processed".
        replace_recent_blockhash: If True the transaction recent blockhash
            will be replaced with the most recent blockhash
            (conflicts with ``sig_verify``).
        min_context_slot: The minimum slot that the request can be evaluated at.
        inner_instructions: If true the response will include inner instructions.
            These inner instructions will be `jsonParsed` where possible, otherwise json.
        accounts_addresses: An array of accounts to return, as base-58 encoded strings
        accounts_encoding: Encoding for returned Account data.
            Note: jsonParsed encoding attempts to use program-specific state parsers to return more
            human-readable and explicit account state data. If jsonParsed is requested but a parser
            cannot be found, the field falls back to base64 encoding, detectable when the returned
            accounts field is type string.

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> full_signed_tx_hex = (
        ...     '01b3795ccfaac3eee838bb05c3b8284122c18acedcd645c914fe8e178c3b62640d8616d061cc818b26cab8ecf3855ecc'
        ...     '72fa113f731ecbd0215e88edc0309d6f0a010001031398f62c6d1a457c51ba6a4b5f3dbd2f69fca93216218dc8997e41'
        ...     '6bd17d93ca68ab4677ffb1f2894dd0a6153c231d45ec436ae53ae60149dbe15f32e4b8703f0000000000000000000000'
        ...     '000000000000000000000000000000000000000000839618f701ba7e9ba27ae59825dd6d6bb66d14f6d5d0eae215161d7'
        ...     '1851a106901020200010c0200000040420f0000000000'
        ... )
        >>> tx = VersionedTransaction.from_bytes(bytes.fromhex(full_signed_tx_hex))
        >>> (await solana_client.simulate_transaction(tx)).value.logs  # doctest: +SKIP
        ['BPF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success']
    """
    body = self._simulate_transaction_body(
        txn,
        sig_verify,
        commitment,
        replace_recent_blockhash,
        min_context_slot,
        inner_instructions,
        accounts_addresses,
        accounts_encoding,
    )
    return await self._provider.make_request(body, SimulateTransactionResp)

validator_exit() async

Request to have the validator exit.

Validator must have booted with RPC exit enabled (--enable-rpc-exit parameter).

Example

solana_client = AsyncClient("http://localhost:8899") (await solana_client.validator_exit()).value # doctest: +SKIP True

Source code in src/solana/rpc/async_api.py
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
async def validator_exit(self) -> ValidatorExitResp:
    """Request to have the validator exit.

    Validator must have booted with RPC exit enabled (`--enable-rpc-exit` parameter).

    Example:
        >>> solana_client = AsyncClient("http://localhost:8899")
        >>> (await solana_client.validator_exit()).value # doctest: +SKIP
        True
    """
    return await self._provider.make_request(self._validator_exit, ValidatorExitResp)  # type: ignore