Skip to main content

almanak_library.models.transaction

json

uuid

datetime

Any

Dict

Optional

BaseModel

Field

ExecutionStatus

TransactionType

deserialize_timestamp

serialize_timestamp

Transaction Objects

class Transaction(BaseModel)

Represents a blockchain transaction.

Attributes:

  • type TransactionType - The type of the transaction.
  • dict Dict[str, Any] - The transaction details in dictionary format.
  • action_id uuid.UUID - The UUID of the associated action.
  • id uuid.UUID - A unique identifier for the transaction, generated at creation.
  • tx_hash Optional[str] - The transaction hash, which uniquely identifies the transaction on the blockchain. This is set after the transaction is signed and broadcasted.
  • from_address Optional[str] - The address from which the transaction originates.
  • created_at float - The timestamp when the transaction was created.

Methods:

get_type() -> TransactionType: Returns the type of the transaction.

get_dict() -> Dict[str, Any]: Returns the transaction details as a dictionary.

get_action_id() -> uuid.UUID: Returns the UUID of the associated action.

get_id() -> str: Returns the unique identifier for the transaction. If the transaction hash (tx_hash) is available, it is returned as the ID. Otherwise, the UUID (id) generated at creation is returned.

get_from_address() -> Optional[str]: Returns the address from which the transaction originates.

get_created_at() -> float: Returns the timestamp when the transaction was created.

str() -> str: Returns a string representation of the transaction, including its ID, type, action ID, creation time, and other relevant details.

model_dump(*args, **kwargs) -> dict: Returns a dictionary representation of the transaction suitable for serialization. This includes converting types to their appropriate serialized forms and ensuring the correct ID (either tx_hash or id) is used.

model_validate(cls, obj) -> 'Transaction': Validates and converts a dictionary representation of a transaction into a dict1 object, ensuring correct types and deserialization of fields.

from_json(cls, json_str: str) -> 'Transaction': Creates a dict1 object from a JSON string representation.

type

tx_dict

action_id

id

from_address

tx_hash

tx_status

created_at

Config Objects

class Config()

arbitrary_types_allowed

json_encoders

get_type

def get_type() -> TransactionType

get_dict

def get_dict() -> Dict[str, Any]

get_action_id

def get_action_id() -> uuid.UUID

get_id

def get_id() -> uuid.UUID

get_from_address

def get_from_address() -> Optional[str]

get_created_at

def get_created_at() -> float

__str__

def __str__()

model_dump

def model_dump(*args, **kwargs)

model_validate

@classmethod
def model_validate(cls, obj)

from_json

@classmethod
def from_json(cls, json_str: str)