TxObject

TxObject is one of the central entity of the Python SDK, and it represent a transaction object.

class aeternity.transactions.TxObject(**kwargs)[source]

This is a TxObject that is used throughout the SDK for transactions It contains all the info associated with a transaction

ga_meta(name)[source]

Get the value of a GA meta transaction property

Parameters

name – the name of the property to get

Returns

the property value or None if there is no such property

get(name)[source]

Get the value of a property of the transaction by name, searching recursively in the TxObject structure.

For GA transaction the properties of the GA use the ga_meta() method below

Parameters

name – the name of the property to get

Returns

the property value or None if there is no such property

meta(name)[source]

Get the value of a meta property such as the min_fee.

Parameters

name – the name of the meta property

Returns

the value of the meta property or none if not found

The fields of a TxObject are

  • hash: the transaction hash

  • data: the transaction data, it varies for every transaction type

  • metadata: it contains additional data that may be relevant in the transaction context

  • tx: the rlp + base64 check encoded string of the transaction that is used to broadcast a transaction

Since a transaction can be a nested structured, the TxObject is nested as well: considering a simple spend transaction, the actual structure of the transaction is:

SignedTx(
  tag:                  - signed transaction type (11)
  version               - transaction version, 1 in this case
  [signature]           - the list of signatures for the signed transaction
  tx: SpendTx(          - the inner spend transaction
    tag                 - spend transaction type (12)
    version             - spend transaction version, 1 in this case
    sender_id           - spend sender
    recipient_id        - spend recipient
    amount              - amount being transferred
    fee                 - fee for the miner
    ttl                 - the mempool time to live
    nonce               - sender account nonce
    payload             - arbitrary payload
  )
)

This means that to access, for example, the spend transaction recipient_id from a TxObject, the code would be:

tx_object = node_cli.spend(sender, recipient, "100AE")
# access the recipient_id
tx_object.data.tx.data.recipient_id

unless the transaction has been posted from a generalized account, in which case there are 4 levels of nesting:

tx_object = node_cli.spend(sender, recipient, "100AE")
# access the recipient_id for a GA generated transaction
tx_object.data.tx.data.tx.data.tx.data.recipient_id

This is of course somewhat awkward, and therefore the TxObject provides the get(NAME), meta(NAME), ga_meta(NAME) functions.

The functions are used to access the values of the properties without worrying about the structure of the transaction, so the example above will become:

tx_object = node_cli.spend(sender, recipient, "100AE")
# access the recipient_id for any spend transaction
tx_object.get("recipient_id")

Metadata

Metadatas are special informations that are not part of the transaction itself but my be generated ad a additional output while creating or parsing a transaction, in particular metadata fields are:

  • min_fee minimum fee for a transaction, this value is always calculaed and can be used to evaluate the actual fee used for the transaction.

  • contract_id the id of a contract, only present when deploying a new contract (starts with prefix ct_).

  • salt the random generated salt to prepare the commitment_id of a name pre-claim transaction. The salt must be used then to prepare a claim transaction.

TxObject data fields

Here is the complete list of transactions and available fields:

(idf.OBJECT_TAG_SIGNED_TRANSACTION, 1): {
    "fee": None,  # signed transactions do not have fees
    "schema": {
        "version": Fd(1),
        "signatures": Fd(2, _SG, prefix=idf.SIGNATURE),  # list
        "tx": Fd(3, _TX, prefix=idf.TRANSACTION),
    }
},
(idf.OBJECT_TAG_SPEND_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "sender_id": Fd(2, _ID),
        "recipient_id": Fd(3, _ID),
        "amount": Fd(4),
        "fee": Fd(5),
        "ttl": Fd(6),
        "nonce": Fd(7),
        "payload": Fd(8, _ENC, prefix=idf.BYTE_ARRAY),
    }
},
(idf.OBJECT_TAG_NAME_SERVICE_PRECLAIM_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "commitment_id": Fd(4, _ID),
        "fee": Fd(5),
        "ttl": Fd(6),
    }},
(idf.OBJECT_TAG_NAME_SERVICE_CLAIM_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "name": Fd(4, _BIN, data_type=str),
        "name_salt": Fd(5),
        "fee": Fd(6),
        "ttl": Fd(7),
    }},
(idf.OBJECT_TAG_NAME_SERVICE_CLAIM_TRANSACTION, 2): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "name": Fd(4, _BIN, data_type=str),
        "name_salt": Fd(5),
        "name_fee": Fd(6),
        "fee": Fd(7),
        "ttl": Fd(8),
    }},
(idf.OBJECT_TAG_NAME_SERVICE_UPDATE_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "name_id": Fd(4, _ID),
        "name_ttl": Fd(5),
        "pointers": Fd(6, _PTR),
        "client_ttl": Fd(7),
        "fee": Fd(8),
        "ttl": Fd(9),
    }},
(idf.OBJECT_TAG_NAME_SERVICE_TRANSFER_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "name_id": Fd(4, _ID),
        "recipient_id": Fd(5, _ID),
        "fee": Fd(6),
        "ttl": Fd(7),
    }},
(idf.OBJECT_TAG_NAME_SERVICE_REVOKE_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "name_id": Fd(4, _ID),
        "fee": Fd(5),
        "ttl": Fd(6),
    }},
(idf.OBJECT_TAG_CONTRACT_CREATE_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED, base_gas_multiplier=5),
    "schema": {
        "version": Fd(1),
        "owner_id": Fd(2, _ID),
        "nonce": Fd(3),
        "code": Fd(4, _ENC, prefix=idf.BYTECODE),
        # "vm_version": Fd(5),
        "abi_version": Fd(5, _VM_ABI),
        "fee": Fd(6),
        "ttl": Fd(7),
        "deposit": Fd(8),
        "amount": Fd(9),
        "gas": Fd(10),
        "gas_price": Fd(11),
        "call_data": Fd(12, _ENC, prefix=idf.BYTECODE),
    }},
(idf.OBJECT_TAG_CONTRACT_CALL_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED, base_gas_multiplier=(
        'abi_version', {
            idf.ABI_FATE: 12,
            idf.ABI_SOPHIA: 30
        })),
    "schema": {
        "version": Fd(1),
        "caller_id": Fd(2, _ID),
        "nonce": Fd(3),
        "contract_id": Fd(4, _ID),
        "abi_version": Fd(5),
        "fee": Fd(6),
        "ttl": Fd(7),
        "amount": Fd(8),
        "gas": Fd(9),
        "gas_price": Fd(10),
        "call_data": Fd(11, _ENC, prefix=idf.BYTECODE),
    }},
(idf.OBJECT_TAG_CHANNEL_CREATE_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "initiator": Fd(2, _ID),
        "initiator_amount": Fd(3),
        "responder": Fd(4, _ID),
        "responder_amount": Fd(5),
        "channel_reserve": Fd(6),
        "lock_period": Fd(7),
        "ttl": Fd(8),
        "fee": Fd(9),
        "delegate_ids": Fd(10, _IDS),  # [d(d) for d in tx_native[10]], TODO: are u sure
        "state_hash": Fd(11, _ENC, prefix=idf.STATE_HASH),
        "nonce": Fd(12),
    }},
(idf.OBJECT_TAG_CHANNEL_DEPOSIT_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "amount": Fd(4),
        "ttl": Fd(5),
        "fee": Fd(6),
        "state_hash": Fd(7, _ENC, prefix=idf.STATE_HASH),  # _binary_decode(tx_native[7]),
        "round": Fd(8),
        "nonce": Fd(9),
    }},
(idf.OBJECT_TAG_CHANNEL_WITHDRAW_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "to_id": Fd(3, _ID),
        "amount": Fd(4),
        "ttl": Fd(5),
        "fee": Fd(6),
        "state_hash": Fd(7, _ENC, prefix=idf.STATE_HASH),  # _binary_decode(tx_native[7]),
        "round": Fd(8),
        "nonce": Fd(9),
    }},
(idf.OBJECT_TAG_CHANNEL_CLOSE_MUTUAL_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "initiator_amount_final": Fd(4),
        "responder_amount_final": Fd(5),
        "ttl": Fd(6),
        "fee": Fd(7),
        "nonce": Fd(8),
    }},
(idf.OBJECT_TAG_CHANNEL_CLOSE_SOLO_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "payload": Fd(4, _ENC, prefix=idf.BYTE_ARRAY),
        "poi": Fd(5, _POI),
        "ttl": Fd(6),
        "fee": Fd(7),
        "nonce": Fd(8),
    }},
(idf.OBJECT_TAG_CHANNEL_SLASH_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "payload": Fd(4, _ENC, prefix=idf.BYTE_ARRAY),
        "poi": Fd(5, _POI),
        "ttl": Fd(6),
        "fee": Fd(7),
        "nonce": Fd(8),
    }},
(idf.OBJECT_TAG_CHANNEL_SETTLE_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "initiator_amount_final": Fd(4),
        "responder_amount_final": Fd(5),
        "ttl": Fd(6),
        "fee": Fd(7),
        "nonce": Fd(8),
    }},
(idf.OBJECT_TAG_CHANNEL_SNAPSHOT_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "payload": Fd(4, _ENC, prefix=idf.BYTE_ARRAY),
        "ttl": Fd(5),
        "fee": Fd(6),
        "nonce": Fd(7),
    }},
(idf.OBJECT_TAG_CHANNEL_FORCE_PROGRESS_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED),
    "schema": {
        "version": Fd(1),
        "channel_id": Fd(2, _ID),
        "from_id": Fd(3, _ID),
        "payload": Fd(4, _ENC, prefix=idf.BYTE_ARRAY),
        "round": Fd(5),
        "update": Fd(6),  # _binary_decode(tx_native[2]),
        "state_hash": Fd(7, _ENC, prefix=idf.STATE_HASH),  # _binary_decode(tx_native[2]),
        "offchain_trees": Fd(8, _TR),  # TODO: implement support for _trees
        "ttl": Fd(2),
        "fee": Fd(2),
        "nonce": Fd(2),
    }},
(idf.OBJECT_TAG_ORACLE_REGISTER_TRANSACTION, 1): {
    "fee": Fee(TTL_BASED, ttl_field="oracle_ttl_value"),
    "schema": {
        "version": Fd(1),
        "account_id": Fd(2, _ID),
        "nonce": Fd(3),
        "query_format": Fd(4, _BIN),  # _binary_decode(tx_native[4]), TODO: verify the type
        "response_format": Fd(5, _BIN),  # _binary_decode(tx_native[5]),
        "query_fee": Fd(6),
        "oracle_ttl_type": Fd(7, _OTTL_TYPE),
        "oracle_ttl_value": Fd(8),
        "fee": Fd(9),
        "ttl": Fd(10),
        "vm_version": Fd(11),
    }},
(idf.OBJECT_TAG_ORACLE_QUERY_TRANSACTION, 1): {
    "fee": Fee(TTL_BASED, ttl_field="query_ttl_value"),
    "schema": {
        "version": Fd(1),
        "sender_id": Fd(2, _ID),
        "nonce": Fd(3),
        "oracle_id": Fd(4, _ID),
        "query": Fd(5, _BIN),
        "query_fee": Fd(6),
        "query_ttl_type": Fd(7, _OTTL_TYPE),
        "query_ttl_value": Fd(8),
        "response_ttl_type": Fd(9, _OTTL_TYPE),
        "response_ttl_value": Fd(10),
        "fee": Fd(11),
        "ttl": Fd(12),
    }},
(idf.OBJECT_TAG_ORACLE_RESPONSE_TRANSACTION, 1): {
    "fee": Fee(TTL_BASED, ttl_field="response_ttl_value"),
    "schema": {
        "version": Fd(1),
        "oracle_id": Fd(2, _ID),
        "nonce": Fd(3),
        "query_id": Fd(4, _ENC, prefix=idf.ORACLE_QUERY_ID),
        "response": Fd(5, _BIN),
        "response_ttl_type": Fd(6, _OTTL_TYPE),
        "response_ttl_value": Fd(7),
        "fee": Fd(8),
        "ttl": Fd(9),
    }},
(idf.OBJECT_TAG_ORACLE_EXTEND_TRANSACTION, 1): {
    "fee": Fee(TTL_BASED, ttl_field="oracle_ttl_value"),
    "schema": {
        "version": Fd(1),
        "oracle_id": Fd(2, _ID),
        "nonce": Fd(3),
        "oracle_ttl_type": Fd(4, _OTTL_TYPE),
        "oracle_ttl_value": Fd(5),
        "fee": Fd(6),
        "ttl": Fd(7),
    }},
(idf.OBJECT_TAG_GA_ATTACH_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED, base_gas_multiplier=5),
    "schema": {
        "version": Fd(1),
        "owner_id": Fd(2, _ID),
        "nonce": Fd(3),
        "code": Fd(4, _ENC, prefix=idf.BYTECODE),
        "auth_fun": Fd(5, _BIN),
        # "vm_version": Fd(6), # This field is retrieved via abi_version
        "abi_version": Fd(6, _VM_ABI),
        "fee": Fd(7),
        "ttl": Fd(8),
        "gas": Fd(9),
        "gas_price": Fd(10),
        "call_data": Fd(11, _ENC, prefix=idf.BYTECODE),  # _binary_decode(tx_native[11]),
    }},
(idf.OBJECT_TAG_GA_META_TRANSACTION, 1): {
    "fee": Fee(SIZE_BASED, base_gas_multiplier=5),
    "schema": {
        "version": Fd(1),
        "ga_id": Fd(2, _ID),
        "auth_data": Fd(3, _ENC, prefix=idf.BYTECODE),
        "abi_version": Fd(4),
        "fee": Fd(5),
        "gas": Fd(6),
        "gas_price": Fd(7),
        "ttl": Fd(8),
        "tx": Fd(9, _TX),
    }
},