Transaction
Transaction Module:
- Bindings
AllAllWAnyAnyWArithmeticArithmetic2AutoWBalanceBridgeBridgeInstructionBurnCounterpartyDeleteExprFiniteInstructionIntentLitMintNonEmptyOrIntentReceiveRelationRestrictionSendSetIntentSignatureSignedTemporaryTokenTransactionTransferFundsVarVariableVariableTagWitnessdumps()loads()- Core Classes
- Enumerations
- Utility Functions
Transaction creation, signing, and submission.
Transaction handling module for the Saline SDK.
This module provides functions for creating, signing, and encoding transactions for submission to the Saline network.
- saline_sdk.transaction.tx.encodeSignedTx(signed)[source]
Encode a signed transaction for network submission.
- saline_sdk.transaction.tx.prepareSimpleTx(signer, tx)[source]
Prepare a simple transaction by signing it with a generated nonce.
This is a convenience function that generates a nonce, signs the transaction, and encodes it in a single step.
- Parameters:
signer (
Union[Account,Subaccount]) – Account or Subaccount to sign withtx (
Transaction) – Transaction object to sign
- Return type:
- Returns:
Base64 encoded transaction ready for submission
- saline_sdk.transaction.tx.print_tx_errors(result, label='Transaction')[source]
Print error details from a Tendermint transaction result.
This function checks the ‘check_tx’ and ‘deliver_tx’ phases of a transaction result. If either phase has a non-zero ‘code’, it prints the phase, error code, and attempts to decode the ‘data’ field from Base64 to provide a human-readable error message.
- saline_sdk.transaction.tx.sign(account, nonce, tx)[source]
Sign a transaction with the given account and nonce.
- Parameters:
account (
Union[Account,Subaccount]) – Account or Subaccount to sign withnonce (
str) – Unique nonce for this signaturetx (
Transaction) – Transaction object to sign
- Return type:
- Returns:
Signed transaction object
- Raises:
AttributeError – If the account does not support signing
- saline_sdk.transaction.tx.tx_is_accepted(result)[source]
Determine if a Tendermint transaction was accepted.
A transaction is considered accepted if both ‘check_tx’ and ‘deliver_tx’ phases have a ‘code’ of 0, indicating success.
check_tx -> pre-flight - transaction is rejectd deliver_tx -> state changed - Transaction is recorded with failure status
Instructions
Transaction instructions module for the Saline SDK.
This module provides helper functions for creating various transaction instructions that can be used when building transactions for the Saline network.
- saline_sdk.transaction.instructions.set_intent(signer_pk, condition_type='ConditionTag_Signature')[source]
Create an intent mask entry for authorizations.
- Parameters:
- Return type:
- Returns:
Intent mask entry for use in transactions
Example
>>> set_intent("signer_public_key")
- saline_sdk.transaction.instructions.swap(sender, recipient, give_token, give_amount, take_token, take_amount)[source]
Create a pair of instructions for a token swap.
- Parameters:
- Return type:
- Returns:
List of two transfer instructions that make up the swap
Example
>>> swap("alice_pk", "bob_pk", "USDC", 100, "BTC", 0.001)
Serialization
Transaction encoding for Saline SDK.
This module handles transaction serialization for both network transmission and signature generation, specifically designed to match Saline’s implementation’s expectations.
- saline_sdk.transaction.serialisation.decode_base64(data)[source]
Decode base64 string to binary data.
- Parameters:
data (
str) – Base64 encoded string- Return type:
- Returns:
Decoded binary data
- Raises:
ValueError – If input is not valid base64
- saline_sdk.transaction.serialisation.decode_network_tx(data)[source]
Decode a transaction received from the network.
- Parameters:
data (
bytes) – The encoded transaction bytes- Return type:
- Returns:
Decoded transaction dictionary
- Raises:
ValueError – If data is invalid
- saline_sdk.transaction.serialisation.encode_base64(data)[source]
Encode binary data as base64 string.
- saline_sdk.transaction.serialisation.serialize_for_network(tx)[source]
Serialize transaction for network submission.
Saline requires a hexadecimal encoding with fields in a specific order: 1. Sort all nested dictionaries for deterministic output 2. Convert to JSON with field ordering preserved 3. Encode as hex (base16)
Transaction Class
Transaction Operations
- saline_sdk.transaction.tx.prepareSimpleTx(signer, tx)[source]
Prepare a simple transaction by signing it with a generated nonce.
This is a convenience function that generates a nonce, signs the transaction, and encodes it in a single step.
- Parameters:
signer (
Union[Account,Subaccount]) – Account or Subaccount to sign withtx (
Transaction) – Transaction object to sign
- Return type:
- Returns:
Base64 encoded transaction ready for submission
- saline_sdk.transaction.tx.encodeSignedTx(signed)[source]
Encode a signed transaction for network submission.
- saline_sdk.transaction.tx.sign(account, nonce, tx)[source]
Sign a transaction with the given account and nonce.
- Parameters:
account (
Union[Account,Subaccount]) – Account or Subaccount to sign withnonce (
str) – Unique nonce for this signaturetx (
Transaction) – Transaction object to sign
- Return type:
- Returns:
Signed transaction object
- Raises:
AttributeError – If the account does not support signing
Transaction Instructions
- saline_sdk.transaction.instructions.transfer(sender, recipient, token, amount)[source]
Create a transfer instruction for sending tokens.
- Parameters:
- Return type:
- Returns:
TransferFunds instruction
Example
>>> transfer("sender_public_key", "recipient_public_key", "USDC", 100)
- saline_sdk.transaction.instructions.swap(sender, recipient, give_token, give_amount, take_token, take_amount)[source]
Create a pair of instructions for a token swap.
- Parameters:
- Return type:
- Returns:
List of two transfer instructions that make up the swap
Example
>>> swap("alice_pk", "bob_pk", "USDC", 100, "BTC", 0.001)
Transaction Serialization
Transaction encoding for Saline SDK.
This module handles transaction serialization for both network transmission and signature generation, specifically designed to match Saline’s implementation’s expectations.
- saline_sdk.transaction.serialisation.decode_base64(data)[source]
Decode base64 string to binary data.
- Parameters:
data (
str) – Base64 encoded string- Return type:
- Returns:
Decoded binary data
- Raises:
ValueError – If input is not valid base64
- saline_sdk.transaction.serialisation.decode_network_tx(data)[source]
Decode a transaction received from the network.
- Parameters:
data (
bytes) – The encoded transaction bytes- Return type:
- Returns:
Decoded transaction dictionary
- Raises:
ValueError – If data is invalid
- saline_sdk.transaction.serialisation.encode_base64(data)[source]
Encode binary data as base64 string.
- saline_sdk.transaction.serialisation.serialize_for_network(tx)[source]
Serialize transaction for network submission.
Saline requires a hexadecimal encoding with fields in a specific order: 1. Sort all nested dictionaries for deterministic output 2. Convert to JSON with field ordering preserved 3. Encode as hex (base16)