Skip to content

RPC Models

solana.rpc.models

Pydantic models for RPC types.

These are the Pydantic successors to the deprecated NamedTuple types in :mod:solana.rpc.types. They carry the same field names and defaults, so migrating is a matter of changing the import path.

ClusterUrls

A collection of urls for each cluster.

Source code in src/solana/rpc/models.py
53
54
55
56
57
58
class ClusterUrls(PydanticModel):
    """A collection of urls for each cluster."""

    devnet: str
    testnet: str
    mainnet_beta: str

DataSliceOpts

Option to limit the returned account data, only available for "base58" or "base64" encoding.

Source code in src/solana/rpc/models.py
19
20
21
22
23
24
25
class DataSliceOpts(PydanticModel):
    """Option to limit the returned account data, only available for "base58" or "base64" encoding."""

    offset: int
    """Limit the returned account data using the provided offset: <usize>."""
    length: int
    """Limit the returned account data using the provided length: <usize>."""

length instance-attribute

Limit the returned account data using the provided length: .

offset instance-attribute

Limit the returned account data using the provided offset: .

Endpoint

Container for http and https cluster urls.

Source code in src/solana/rpc/models.py
61
62
63
64
65
class Endpoint(PydanticModel):
    """Container for http and https cluster urls."""

    http: ClusterUrls
    https: ClusterUrls

MemcmpOpts

Option to compare a provided series of bytes with program account data at a particular offset.

Source code in src/solana/rpc/models.py
28
29
30
31
32
33
34
class MemcmpOpts(PydanticModel):
    """Option to compare a provided series of bytes with program account data at a particular offset."""

    offset: int
    """Offset into program account data to start comparison: <usize>."""
    bytes: str
    """Data to match, as base-58 encoded string: <string>."""

bytes instance-attribute

Data to match, as base-58 encoded string: .

offset instance-attribute

Offset into program account data to start comparison: .

TokenAccountOpts

Options when querying token accounts.

Provide one of mint or program_id.

Source code in src/solana/rpc/models.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class TokenAccountOpts(PydanticModel):
    """Options when querying token accounts.

    Provide one of mint or program_id.
    """

    mint: Optional[Pubkey] = None
    """Public key of the specific token Mint to limit accounts to."""
    program_id: Optional[Pubkey] = None
    """Public key of the Token program ID that owns the accounts."""
    encoding: str = "base64"
    """Encoding for Account data, either "base58" (slow) or "base64"."""
    data_slice: Optional[DataSliceOpts] = None
    """Option to limit the returned account data, only available for "base58" or "base64" encoding."""

data_slice = None class-attribute instance-attribute

Option to limit the returned account data, only available for "base58" or "base64" encoding.

encoding = 'base64' class-attribute instance-attribute

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

mint = None class-attribute instance-attribute

Public key of the specific token Mint to limit accounts to.

program_id = None class-attribute instance-attribute

Public key of the Token program ID that owns the accounts.

TxOpts

Options to specify when broadcasting a transaction.

Source code in src/solana/rpc/models.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class TxOpts(PydanticModel):
    """Options to specify when broadcasting a transaction."""

    skip_confirmation: bool = True
    """If false, `send_transaction` will try to confirm that the transaction was successfully broadcasted.

    When confirming a transaction, `send_transaction` will block for a maximum of 30 seconds. Wrap the call
    inside a thread to make it asynchronous.
    """
    skip_preflight: bool = False
    """If true, skip the preflight transaction checks."""
    preflight_commitment: Commitment = Finalized
    """Commitment level to use for preflight."""
    max_retries: Optional[int] = None
    """Maximum number of times for the RPC node to retry sending the transaction to the leader.
    If this parameter not provided, the RPC node will retry the transaction until it is finalized
    or until the blockhash expires.
    """
    last_valid_block_height: Optional[int] = None
    """Pass the latest valid block height here, to be consumed by confirm_transaction.
    Valid only if skip_confirmation is False.
    """

last_valid_block_height = None class-attribute instance-attribute

Pass the latest valid block height here, to be consumed by confirm_transaction. Valid only if skip_confirmation is False.

max_retries = None class-attribute instance-attribute

Maximum number of times for the RPC node to retry sending the transaction to the leader. If this parameter not provided, the RPC node will retry the transaction until it is finalized or until the blockhash expires.

preflight_commitment = Finalized class-attribute instance-attribute

Commitment level to use for preflight.

skip_confirmation = True class-attribute instance-attribute

If false, send_transaction will try to confirm that the transaction was successfully broadcasted.

When confirming a transaction, send_transaction will block for a maximum of 30 seconds. Wrap the call inside a thread to make it asynchronous.

skip_preflight = False class-attribute instance-attribute

If true, skip the preflight transaction checks.