RPC

RPC client for interacting with Saline nodes.

This module provides a unified client for submitting transactions and querying the Saline network.

IMPORTANT: Saline nodes and Tendermint RPC endpoints have specific behaviors:

  1. Transaction Broadcasting: - broadcast_tx_commit and broadcast_tx_sync will return errors like

    “Failed decode: Error in $: not enough input” even for valid transactions if decoded incorrectly.

    • broadcast_tx_async is more permissive and will accept transactions, returning a transaction hash even if the transaction cannot be decoded.

  2. Transaction Format: - Transactions must be properly serialized as JSON and base64 encoded. - POST requests with parameters in the body are more reliable than GET requests

    with URL parameters.

  3. Error Handling: - Error responses often include hex-encoded error messages which need to be

    decoded for human readability.

Note on method naming conventions: - Transaction broadcasting methods use descriptive names (tx_fire, tx_broadcast, tx_commit)

that match the behavior rather than the RPC endpoint names

class saline_sdk.rpc.client.Client(http_url='http://localhost:26657', debug=False)[source]

Bases: object

Unified client for interacting with Saline nodes.

Provides HTTP RPC connectivity to Saline nodes with functionality for: - Transaction broadcasting - Block and transaction querying - Balance querying - Intent querying and parsing - Wallet information retrieval - Aggregate balance queries

Methods are provided in both asynchronous and synchronous versions: - Asynchronous methods (default) have no suffix - Synchronous wrappers have the _sync suffix

Transaction broadcasting methods use descriptive names: - tx_fire: Fire-and-forget transaction (broadcast_tx_async RPC) - tx_broadcast: Submit and check transaction (broadcast_tx_sync RPC) - tx_commit: Submit and wait for block commit (broadcast_tx_commit RPC)

Initialize the client.

Parameters:
  • http_url (str) – Base URL for HTTP RPC endpoints

  • debug (bool) – Enable debug logging

__init__(http_url='http://localhost:26657', debug=False)[source]

Initialize the client.

Parameters:
  • http_url (str) – Base URL for HTTP RPC endpoints

  • debug (bool) – Enable debug logging

async abci_query_async(path, data, height=0, prove=False)[source]

Make a direct ABCI query asynchronously.

Parameters:
  • path (str) – Query path (e.g., “/store/balance”, “/store/intent”)

  • data (str) – Query data (hex-encoded)

  • height (int) – Block height (0 for latest)

  • prove (bool) – Whether to include proofs

Return type:

Dict[str, Any]

Returns:

Query result

async get_all_balances_async(address)[source]

Get balances for all tokens for an address asynchronously.

Parameters:

address (str) – Account address to query

Return type:

Dict[str, float]

Returns:

Dictionary mapping token symbols to balances

async get_all_intents()[source]

Get all intents in the system asynchronously.

This method queries the node for all registered intents and parses them into specialized Intent objects from the SDK. It handles various intent types including All, Any, Restriction, Finite, Temporary and Signature intents.

Return type:

ParsedAllIntentsResponse

Returns:

ParsedAllIntentsResponse object containing a dictionary of ParsedIntentInfo objects.

async get_balance_async(address, token='USDC')[source]

Get the balance of a specific token for an address asynchronously.

Parameters:
  • address (str) – Account address to query

  • token (str) – Token symbol (e.g., “USDC”, “ETH”)

Return type:

Optional[float]

Returns:

Balance amount or None if not found

async get_block(height=None)[source]

Get block at specified height or latest if not specified.

Return type:

Dict[str, Any]

Parameters:

height (int | None)

async get_current_block()[source]

Get the current block.

Return type:

Dict[str, Any]

async get_status()[source]

Get node status asynchronously.

Return type:

Dict[str, Any]

Returns:

Node status information

async get_transactions(height=None)[source]

Get transactions from a block at specified height or latest if not specified.

Return type:

List[Dict[str, Any]]

Parameters:

height (int | None)

async get_tx(tx_hash)[source]

Get transaction by hash.

Return type:

Dict[str, Any]

Parameters:

tx_hash (str)

async get_wallet_info_async(address)[source]

Get wallet information for an address asynchronously.

This method retrieves comprehensive information about a wallet, including: - All token balances - The wallet’s intent (parsed into an SDK Intent object)

Parameters:

address (str) – Address to get wallet info for

Return type:

ParsedWalletInfo

Returns:

ParsedWalletInfo dataclass containing parsed balances and intent.

async tx_broadcast(tx_bytes)[source]

Broadcast a transaction and wait for validation (using broadcast_tx_sync RPC).

Submit and check - waits for the transaction to be validated but not committed.

Parameters:

tx_bytes (str) – Base64-encoded transaction bytes

Return type:

Dict[str, Any]

Returns:

Transaction receipt with validation results

async tx_commit(tx_bytes)[source]

Broadcast a transaction and wait for it to be committed (using broadcast_tx_commit RPC).

Submit and wait - waits for the transaction to be committed.

Parameters:

tx_bytes (str) – Base64-encoded transaction bytes

Return type:

Dict[str, Any]

Returns:

Transaction receipt with commit results

async tx_fire(tx_bytes)[source]

Fire a transaction and return immediately (using broadcast_tx_async RPC).

Fire and forget - doesn’t wait for any validation.

Parameters:

tx_bytes (str) – Base64-encoded transaction bytes

Return type:

Dict[str, Any]

Returns:

Transaction receipt with hash

Dataclasses for structured RPC query responses, using bindings.py types for intents.

class saline_sdk.rpc.query_responses.ParsedAllIntentsResponse(intents=<factory>)[source]

Bases: object

Wrapper for the result of get_all_intents.

Parameters:

intents (Dict[str, ParsedIntentInfo])

intents: Dict[str, ParsedIntentInfo]
class saline_sdk.rpc.query_responses.ParsedIntentInfo(intent_id, parsed_intent, addresses=<factory>, raw_intent_data=None, error=None)[source]

Bases: object

Holds information about a single intent fetched from the node.

Parameters:
addresses: List[List[str]]
error: Optional[str] = None
intent_id: str
parsed_intent: Optional[Intent]
raw_intent_data: Any = None
class saline_sdk.rpc.query_responses.ParsedWalletInfo(address, balances=<factory>, parsed_intent=None, raw_wallet_data=None, error=None)[source]

Bases: object

Structure holding parsed info from get_wallet_info.

Parameters:
static parse_intent_to_json(x)[source]
Parameters:

x (Intent)

address: str
balances: Dict[str, int]
error: Optional[str] = None
parsed_intent: Optional[Intent] = None
raw_wallet_data: Any = None
saline_sdk.rpc.query_responses.contains_binding_type(node, target_type)[source]

(Optimized) Recursively check if an intent/expression tree contains a node of target_type.

Return type:

bool

Parameters:
saline_sdk.rpc.query_responses.parse_dict_to_binding_intent(raw_intent_data)[source]

Attempts to parse a raw dictionary/list structure into an Intent object from bindings.py using its from_json methods.

Handles potential nesting in the raw data. Returns None if parsing fails or input is invalid.

Return type:

Optional[Intent]

Parameters:

raw_intent_data (Any)

RPC error handling for Saline SDK.

exception saline_sdk.rpc.error.RPCError[source]

Bases: Exception

RPC-related error.