Transaction Methods

Methods for working with transactions on the XRP Ledger.

exception xrpl.transaction.XRPLReliableSubmissionException

Bases: xrpl.constants.XRPLException

General XRPL Reliable Submission Exception.

xrpl.transaction.autofill(transaction: xrpl.models.transactions.transaction.Transaction, client: xrpl.clients.sync_client.SyncClient) xrpl.models.transactions.transaction.Transaction

Autofills fields in a transaction. This will set sequence, fee, and last_ledger_sequence according to the current state of the server this Client is connected to. It also converts all X-Addresses to classic addresses.

Parameters
  • transaction – the transaction to be signed.

  • client – a network client.

Returns

The autofilled transaction.

xrpl.transaction.get_transaction_from_hash(tx_hash: str, client: xrpl.clients.sync_client.SyncClient, binary: bool = False, min_ledger: Optional[int] = None, max_ledger: Optional[int] = None) xrpl.models.response.Response

Given a transaction hash, fetch the corresponding transaction from the ledger.

Parameters
  • tx_hash – the transaction hash.

  • client – the network client used to communicate with a rippled node.

  • binary – If true, return transaction data and metadata as binary serialized to hexadecimal strings. If false, return transaction data and metadata as JSON. The default is false.

  • min_ledger – Use this with max_ledger to specify a range of up to 1000 ledger indexes, starting with this ledger (inclusive). If the server cannot find the transaction, it confirms whether it was able to search all the ledgers in this range.

  • max_ledger – Use this with min_ledger to specify a range of up to 1000 ledger indexes, ending with this ledger (inclusive). If the server cannot find the transaction, it confirms whether it was able to search all the ledgers in the requested range.

Returns

The Response object containing the transaction info.

Raises

XRPLRequestFailureException – if the transaction fails.

xrpl.transaction.safe_sign_and_autofill_transaction(transaction: xrpl.models.transactions.transaction.Transaction, wallet: xrpl.wallet.main.Wallet, client: xrpl.clients.sync_client.SyncClient, check_fee: bool = True) xrpl.models.transactions.transaction.Transaction

Signs a transaction locally, without trusting external rippled nodes. Autofills relevant fields.

Parameters
  • transaction – the transaction to be signed.

  • wallet – the wallet with which to sign the transaction.

  • client – a network client.

  • check_fee – whether to check if the fee is higher than the expected transaction type fee. Defaults to True.

Returns

The signed transaction.

xrpl.transaction.safe_sign_and_submit_transaction(transaction: xrpl.models.transactions.transaction.Transaction, wallet: xrpl.wallet.main.Wallet, client: xrpl.clients.sync_client.SyncClient, autofill: bool = True, check_fee: bool = True) xrpl.models.response.Response

Signs a transaction (locally, without trusting external rippled nodes) and submits it to the XRPL.

Parameters
  • transaction – the transaction to be signed and submitted.

  • wallet – the wallet with which to sign the transaction.

  • client – the network client with which to submit the transaction.

  • autofill – whether to autofill the relevant fields. Defaults to True.

  • check_fee – whether to check if the fee is higher than the expected transaction type fee. Defaults to True.

Returns

The response from the ledger.

xrpl.transaction.safe_sign_transaction(transaction: xrpl.models.transactions.transaction.Transaction, wallet: xrpl.wallet.main.Wallet, check_fee: bool = True) xrpl.models.transactions.transaction.Transaction

Signs a transaction locally, without trusting external rippled nodes.

Parameters
  • transaction – the transaction to be signed.

  • wallet – the wallet with which to sign the transaction.

  • check_fee – whether to check if the fee is higher than the expected transaction type fee. Defaults to True.

Returns

The signed transaction blob.

xrpl.transaction.send_reliable_submission(transaction: xrpl.models.transactions.transaction.Transaction, client: xrpl.clients.sync_client.SyncClient) xrpl.models.response.Response

Submits a transaction and verifies that it has been included in a validated ledger (or has errored/will not be included for some reason).

See Reliable Transaction Submission

Note: This cannot be used with a standalone rippled node, because ledgers do not close automatically.

Parameters
  • transaction – the signed transaction to submit to the ledger. Requires a last_ledger_sequence param.

  • client – the network client used to submit the transaction to a rippled node.

Returns

The response from a validated ledger.

xrpl.transaction.submit_transaction(transaction: xrpl.models.transactions.transaction.Transaction, client: xrpl.clients.sync_client.SyncClient) xrpl.models.response.Response

Submits a transaction to the ledger.

Parameters
  • transaction – the Transaction to be submitted.

  • client – the network client with which to submit the transaction.

Returns

The response from the ledger.

Raises

XRPLRequestFailureException – if the rippled API call fails.

xrpl.transaction.transaction_json_to_binary_codec_form(dictionary: Dict[str, Any]) Dict[str, Any]

Returns a new dictionary in which the keys have been formatted as CamelCase and standardized to be serialized by the binary codec.

Parameters

dictionary – The dictionary to be reformatted.

Returns

A new dictionary object that has been reformatted.