TxBuilder

class aeternity.transactions.TxBuilder(base_gas=15000, gas_per_byte=20, gas_price=1000000000, key_block_interval=3)[source]

TxBuilder is used to build and post transactions to the chain.

Args:

base_gas (int): the base gas value as defined by protocol gas_per_byte (int): the gas per byte as defined by protocol gas_price (int): the gas price as defined by protocol or node configuration key_block_interval (int): the estimated number of minutes between blocks

compute_min_fee(tx_data: dict, tx_descriptor: dict, tx_raw: list) → int[source]

Compute the minimum fee for a transaction

Args:

tx_data (dict): the transaction data tx_descriptor (dict): the descriptor of the transaction fields tx_raw: the unencoded rlp data of the transaction

Returns:

the minimum fee for the transaction

static compute_tx_hash(encoded_tx: str) → str[source]

Generate the hash from a signed and encoded transaction

Args:

encoded_tx (str): an encoded signed transaction

parse_node_reply(tx_data) → aeternity.transactions.TxObject[source]

Parse a node rest api reply to a transaction object

parse_tx_string(tx_string) → aeternity.transactions.TxObject[source]

Parse a transaction string to a transaction object

tx_contract_call(caller_id, contract_id, call_data, function, amount, gas, gas_price, abi_version, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a Contract Call transaction :param caller_id: the account creating the contract :param contract_id: the contract to call :param call_data: the call data for the contract :param function: the function to execute :param amount: the amount associated to the transaction call :param gas: the gas limit for the execution of the function :param gas_price: the gas unit price :param abi_version: TODO: add definition :param fee: the transaction fee :param ttl: the ttl of the transaction :param nonce: the nonce of the account for the transaction

tx_contract_create(owner_id, code, call_data, amount, deposit, gas, gas_price, vm_version, abi_version, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a contract transaction :param owner_id: the account creating the contract :param code: the binary code of the contract :param call_data: the call data for the contract :param amount: initial amount(balance) of the contract :param deposit: the deposit bound to the contract :param gas: the gas limit for the execution of the limit function :param gas_price: the gas price for the unit of gas :param vm_version: the vm version of the contract :param abi_version: TODO: add definition :param fee: the transaction fee :param ttl: the ttl of the transaction :param nonce: the nonce of the account for the transaction

tx_ga_attach(owner_id, nonce, code, auth_fun, vm_version, abi_version, fee, ttl, gas, gas_price, call_data) → aeternity.transactions.TxObject[source]
Parameters
  • owner_id – the owner of the contra

  • nonce – the transaction nonce

  • code – the bytecode of for the generalized account contract

  • auth_fun – the hash of the authorization function of the ga contract

  • vm_version – the vm version of the contract

  • abi_version – TODO: add definition

  • fee – the fee for the transaction

  • ttl – the ttl for the transaction

tx_ga_meta(ga_id, auth_data, abi_version, fee, gas, gas_price, ttl, tx) → aeternity.transactions.TxObject[source]
Parameters
  • ga_id – the account id

  • auth_data – the authorized data

  • abi_version – compiler abi version

  • fee – transaction fee

  • gas – gas limit for the authorization function

  • gas_price – the gas prize

  • ttl – time to live (in height) of the transaction

  • tx – the transaction to be authorized

tx_name_claim(account_id, name, name_salt, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a preclaim transaction :param account_id: the account registering the name :param name: the actual name to claim :param name_salt: the salt used to create the commitment_id during preclaim :param fee: the fee for the transaction :param ttl: the ttl for the transaction :param nonce: the nonce of the account for the transaction

tx_name_claim_v2(account_id, name, name_salt, name_fee, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a preclaim transaction :param account_id: the account registering the name :param name: the actual name to claim :param name_salt: the salt used to create the commitment_id during preclaim :param name_fee: the fee bid to claim the name :param fee: the fee for the transaction :param ttl: the ttl for the transaction :param nonce: the nonce of the account for the transaction

tx_name_preclaim(account_id, commitment_id, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a preclaim transaction :param account_id: the account registering the name :param commitment_id: the commitment id :param fee: the fee for the transaction :param ttl: the ttl for the transaction :param nonce: the nonce of the account for the transaction

tx_name_revoke(account_id, name_id, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a revoke transaction :param account_id: the account revoking the name :param name_id: the name to revoke :param fee: the transaction fee :param ttl: the ttl of the transaction :param nonce: the nonce of the account for the transaction

tx_name_transfer(account_id, name_id, recipient_id, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a transfer transaction :param account_id: the account transferring the name :param name_id: the name to transfer :param recipient_id: the address of the account to transfer the name to :param fee: the transaction fee :param ttl: the ttl of the transaction :param nonce: the nonce of the account for the transaction

tx_name_update(account_id, name_id, pointers, name_ttl, client_ttl, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create an update transaction :param account_id: the account updating the name :param name_id: the name id :param pointers: the pointers to update to :param name_ttl: the ttl for the name registration :param client_ttl: the ttl for client to cache the name :param fee: the transaction fee :param ttl: the ttl of the transaction :param nonce: the nonce of the account for the transaction

tx_oracle_extend(oracle_id, ttl_type, ttl_value, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a oracle extends transaction

tx_oracle_query(oracle_id, sender_id, query, query_fee, query_ttl_type, query_ttl_value, response_ttl_type, response_ttl_value, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a oracle query transaction

tx_oracle_register(account_id, query_format, response_format, query_fee, ttl_type, ttl_value, vm_version, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a register oracle transaction

tx_oracle_respond(oracle_id, query_id, response, response_ttl_type, response_ttl_value, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

Create a oracle response transaction

tx_signed(signatures: list, tx: aeternity.transactions.TxObject, metadata={}) → aeternity.transactions.TxObject[source]

Create a signed transaction. This is a special type of transaction as it wraps a normal transaction adding one or more signature.

Args:

signatures: the signatures to add to the transaction tx (TxObject): the enclosed transaction metadata: additional metadata to be saved in the TxObject

Returns:

the TxObject representing the signed transaction

tx_spend(sender_id, recipient_id, amount, payload, fee, ttl, nonce) → aeternity.transactions.TxObject[source]

create a spend transaction :param sender_id: the public key of the sender :param recipient_id: the public key of the recipient :param amount: the amount to send :param payload: the payload associated with the data :param fee: the fee for the transaction :param ttl: the absolute ttl of the transaction :param nonce: the nonce of the transaction