cardano_clusterlib package
Submodules
cardano_clusterlib.address_group module
Group of methods for working with payment addresses.
- class cardano_clusterlib.address_group.AddressGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- gen_payment_addr(addr_name: str, payment_vkey: str | None = None, payment_vkey_file: str | Path | None = None, payment_script_file: str | Path | None = None, stake_vkey: str | None = None, stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, destination_dir: str | Path = '.') str[source]
Generate a payment address, with optional delegation to a stake address.
- Parameters:
addr_name – A name of payment address.
payment_vkey – A vkey file (Bech32, optional).
payment_vkey_file – A path to corresponding vkey file (optional).
payment_script_file – A path to corresponding payment script file (optional).
stake_vkey – A stake vkey file (optional).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – A stake address (Bech32, optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A generated payment address.
- Return type:
str
- gen_payment_addr_and_keys(name: str, stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, destination_dir: str | Path = '.') AddressRecord[source]
Generate payment address and key pair.
- Parameters:
name – A name of the address and key pair.
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding payment script file (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
- A data container containing the address and
key pair / script file.
- Return type:
- gen_payment_key_pair(key_name: str, extended: bool = False, destination_dir: str | Path = '.') KeyPair[source]
Generate an address key pair.
- Parameters:
key_name – A name of the key pair.
extended – A bool indicating whether to generate extended ed25519 Shelley-era key (False by default).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing the key pair.
- Return type:
- get_address_info(address: str) AddressInfo[source]
Get information about an address.
- Parameters:
address – A Cardano address.
- Returns:
A data container containing address info.
- Return type:
- get_payment_vkey_hash(payment_vkey_file: str | Path | None = None, payment_vkey: str | None = None) str[source]
Return the hash of an address key.
- Parameters:
payment_vkey_file – A path to payment vkey file (optional).
payment_vkey – A payment vkey, (Bech32, optional).
- Returns:
A generated hash.
- Return type:
str
cardano_clusterlib.clusterlib module
Legacy top-level module.
Import everything that used to be available here for backwards compatibility.
cardano_clusterlib.clusterlib_helpers module
Helper functions for ClusterLib.
- class cardano_clusterlib.clusterlib_helpers.EpochInfo(epoch: int, first_slot: int, last_slot: int)[source]
Bases:
object
- cardano_clusterlib.clusterlib_helpers.get_epoch_for_slot(cluster_obj: itp.ClusterLib, slot_no: int) EpochInfo[source]
Given slot number, return corresponding epoch number and first and last slot of the epoch.
- cardano_clusterlib.clusterlib_helpers.get_slots_offset(clusterlib_obj: itp.ClusterLib) int[source]
Get offset of slots from Byron era vs current configuration.
- cardano_clusterlib.clusterlib_helpers.poll_new_epoch(clusterlib_obj: itp.ClusterLib, exp_epoch: int, padding_seconds: int = 0) None[source]
Wait for new epoch(s) by polling current epoch every 3 sec.
Can be used only for waiting up to 3000 sec + padding seconds.
- Parameters:
clusterlib_obj – An instance of ClusterLib.
tip – Current tip - last block successfully applied to the ledger.
exp_epoch – An epoch number to wait for.
padding_seconds – A number of additional seconds to wait for (optional).
- cardano_clusterlib.clusterlib_helpers.wait_for_block(clusterlib_obj: itp.ClusterLib, tip: dict[str, Any], block_no: int) int[source]
Wait for block number.
- Parameters:
clusterlib_obj – An instance of ClusterLib.
tip – Current tip - last block successfully applied to the ledger.
block_no – A block number to wait for.
- Returns:
A block number of last added block.
- Return type:
int
- cardano_clusterlib.clusterlib_helpers.wait_for_epoch(clusterlib_obj: itp.ClusterLib, tip: dict[str, Any], epoch_no: int, padding_seconds: int = 0, future_is_ok: bool = True) int[source]
Wait for epoch no.
- Parameters:
clusterlib_obj – An instance of ClusterLib.
tip – Current tip - last block successfully applied to the ledger.
epoch_no – A number of epoch to wait for.
padding_seconds – A number of additional seconds to wait for (optional).
future_is_ok – A bool indicating whether current epoch > epoch_no is acceptable (default: True).
- Returns:
The current epoch.
- Return type:
int
cardano_clusterlib.clusterlib_klass module
Wrapper for cardano-cli for working with cardano cluster.
- class cardano_clusterlib.clusterlib_klass.ClusterLib(state_dir: str | Path, slots_offset: int | None = None, socket_path: str | Path = '', command_era: str = 'latest')[source]
Bases:
objectMethods for working with cardano cluster using cardano-cli..
- slots_offset[source]
Difference in slots between cluster’s start era and Shelley era (Byron vs Shelley)
- socket_path[source]
A path to socket file for communication with the node. This overrides the CARDANO_NODE_SOCKET_PATH environment variable.
- cli(cli_args: list[str], timeout: float | None = None, add_default_args: bool = True) CLIOut[source]
Run the cardano-cli command.
- Parameters:
cli_args – A list of arguments for cardano-cli.
timeout – A timeout for the command, in seconds (optional).
add_default_args – Whether to add default arguments to the command (optional).
- Returns:
A data container containing command stdout and stderr.
- Return type:
- property g_address: AddressGroup[source]
Address group.
- property g_genesis: GenesisGroup[source]
Genesis group.
- property g_query: QueryGroup[source]
Query group.
- property g_stake_address: StakeAddressGroup[source]
Stake address group.
- property g_stake_pool: StakePoolGroup[source]
Stake pool group.
- property g_transaction: TransactionGroup[source]
Transaction group.
- set_socket_path(socket_path: str | Path | None) None[source]
Set a path to socket file for communication with the node.
- time_from_epoch_start(tip: dict | None = None) float[source]
How many seconds passed from start of the current epoch.
- time_to_epoch_end(tip: dict | None = None) float[source]
How many seconds to go to start of a new epoch.
- wait_for_block(block: int) int[source]
Wait for block number.
- Parameters:
block – A block number to wait for.
- Returns:
A block number of last added block.
- Return type:
int
- wait_for_epoch(epoch_no: int, padding_seconds: int = 0, future_is_ok: bool = True) int[source]
Wait for epoch no.
- Parameters:
epoch_no – A number of epoch to wait for.
padding_seconds – A number of additional seconds to wait for (optional).
future_is_ok – A bool indicating whether current epoch > epoch_no is acceptable (default: True).
- Returns:
The current epoch.
- Return type:
int
- wait_for_new_block(new_blocks: int = 1) int[source]
Wait for new block(s) to be created.
- Parameters:
new_blocks – A number of new blocks to wait for (optional).
- Returns:
A block number of last added block.
- Return type:
int
cardano_clusterlib.consts module
cardano_clusterlib.conway_gov_action_group module
cardano_clusterlib.conway_gov_committee_group module
cardano_clusterlib.conway_gov_drep_group module
cardano_clusterlib.conway_gov_group module
cardano_clusterlib.conway_gov_query_group module
cardano_clusterlib.conway_gov_vote_group module
cardano_clusterlib.coverage module
cardano_clusterlib.exceptions module
cardano_clusterlib.genesis_group module
Group of methods related to genesis block.
- class cardano_clusterlib.genesis_group.GenesisGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- gen_genesis_addr(addr_name: str, vkey_file: str | Path, destination_dir: str | Path = '.') str[source]
Generate the address for an initial UTxO based on the verification key.
- Parameters:
addr_name – A name of genesis address.
vkey_file – A path to corresponding vkey file.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A generated genesis address.
- Return type:
str
- property genesis_keys: GenesisKeys[source]
Return data container with genesis-related keys.
cardano_clusterlib.governance_group module
cardano_clusterlib.helpers module
- cardano_clusterlib.helpers.get_rand_str(length: int = 8) str[source]
Return random ASCII lowercase string.
cardano_clusterlib.key_group module
Group of methods for working with key commands.
- class cardano_clusterlib.key_group.KeyGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- derive_from_mnemonic(key_name: str, key_type: KeyType, mnemonic_file: str | Path, account_number: int = 0, key_number: int | None = None, out_format: OutputFormat = OutputFormat.TEXT_ENVELOPE, destination_dir: str | Path = '.') Path[source]
Derive an extended signing key from a mnemonic sentence.
- Parameters:
key_name – A name of the key.
key_type – A type of the key.
mnemonic_file – A path to a file containing the mnemonic sentence.
account_number – An account number (default is 0).
key_number – A key number (optional, required for payment and stake keys).
out_format – An output format (default is text-envelope).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated extended signing key file.
- Return type:
Path
- gen_mnemonic(size: Literal[12, 15, 18, 21, 24], out_file: str | Path = '') list[str][source]
Generate a mnemonic sentence that can be used for key derivation.
- Parameters:
size – Number of words in the mnemonic (12, 15, 18, 21, or 24).
out_file – A path to a file where the mnemonic will be stored (optional).
- Returns:
A list of words in the generated mnemonic.
- Return type:
list[str]
- gen_non_extended_verification_key(key_name: str, extended_verification_key_file: str | Path, destination_dir: str | Path = '.') Path[source]
Generate a non-extended key from a verification key.
- Parameters:
key_name – A name of the key.
extended_verification_key_file – A path to the extended verification key file.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated non-extended verification key file.
- Return type:
Path
- gen_verification_key(key_name: str, signing_key_file: str | Path, destination_dir: str | Path = '.') Path[source]
Generate a verification file from a signing key.
- Parameters:
key_name – A name of the key.
signing_key_file – A path to signing key file.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated verification key file.
- Return type:
Path
cardano_clusterlib.node_group module
Group of methods for node operation.
- class cardano_clusterlib.node_group.NodeGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- gen_cold_key_pair_and_counter(node_name: str, destination_dir: str | Path = '.') ColdKeyPair[source]
Generate a key pair for operator’s offline key and a new certificate issue counter.
- Parameters:
node_name – A name of the node the key pair and the counter is generated for.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing the key pair and the counter.
- Return type:
- gen_kes_key_pair(node_name: str, destination_dir: str | Path = '.') KeyPair[source]
Generate a key pair for a node KES operational key.
- Parameters:
node_name – A name of the node the key pair is generated for.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing the key pair.
- Return type:
- gen_node_operational_cert(node_name: str, kes_vkey_file: str | Path, cold_skey_file: str | Path, cold_counter_file: str | Path, kes_period: int | None = None, destination_dir: str | Path = '.') Path[source]
Generate a node operational certificate.
This certificate is used when starting the node and not submitted through a transaction.
- Parameters:
node_name – A name of the node the certificate is generated for.
kes_vkey_file – A path to pool KES vkey file.
cold_skey_file – A path to pool cold skey file.
cold_counter_file – A path to pool cold counter file.
kes_period – A start KES period. The current KES period is used when not specified.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_vrf_key_pair(node_name: str, destination_dir: str | Path = '.') KeyPair[source]
Generate a key pair for a node VRF operational key.
- Parameters:
node_name – A name of the node the key pair is generated for.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing the key pair.
- Return type:
cardano_clusterlib.query_group module
Wrapper for cardano-cli for working with cardano cluster.
- class cardano_clusterlib.query_group.QueryGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- get_address_balance(address: str, coin: str = 'lovelace') int[source]
Get total balance of an address (sum of all UTxO balances).
- Parameters:
address – A payment address string.
coin – A coin name (asset IDs).
- Returns:
A total balance.
- Return type:
int
- get_address_deposit(pparams: dict[str, Any] | None = None) int[source]
Return stake address deposit amount.
- get_block_no(tip: dict[str, Any] | None = None) int[source]
Return block number of last block that was successfully applied to the ledger.
- get_drep_stake_distribution(drep_script_hash: str = '', drep_vkey: str = '', drep_vkey_file: str | Path | None = None, drep_key_hash: str = '') dict[str, Any][source]
Get the DRep stake distribution.
When no key is provided, query all DReps.
- Parameters:
drep_script_hash – DRep script hash (hex-encoded, optional).
drep_vkey – DRep verification key (Bech32 or hex-encoded).
drep_vkey_file – Filepath of the DRep verification key.
drep_key_hash – DRep verification key hash (either Bech32-encoded or hex-encoded).
- Returns:
DRep stake distribution.
- Return type:
dict[str, Any]
- get_drep_state(drep_script_hash: str = '', drep_vkey: str = '', drep_vkey_file: str | Path | None = None, drep_key_hash: str = '') list[list[dict[str, Any]]][source]
Get the DRep state.
When no key is provided, query all DReps.
- Parameters:
drep_script_hash – DRep script hash (hex-encoded, optional).
drep_vkey – DRep verification key (Bech32 or hex-encoded).
drep_vkey_file – Filepath of the DRep verification key.
drep_key_hash – DRep verification key hash (either Bech32-encoded or hex-encoded).
- Returns:
DRep state.
- Return type:
list[list[dict[str, Any]]]
- get_epoch(tip: dict[str, Any] | None = None) int[source]
Return epoch of last block that was successfully applied to the ledger.
- get_epoch_slot_no(tip: dict[str, Any] | None = None) int[source]
Return slot number within a given epoch.
(of last block successfully applied to the ledger)
- get_future_pparams() dict[str, Any][source]
Get the future protocol parameters that will apply at the next epoch.
- get_gov_action_deposit(pparams: dict[str, Any] | None = None) int[source]
Return governance action deposit amount.
- get_kes_period_info(opcert_file: str | Path) dict[str, Any][source]
Get information about the current KES period and node’s operational certificate.
- Parameters:
opcert_file – A path to operational certificate.
- Returns:
A dictionary containing KES period information.
- Return type:
dict
- get_leadership_schedule(vrf_skey_file: str | Path, stake_pool_vkey: str = '', cold_vkey_file: str | Path | None = None, stake_pool_id: str = '', for_next: bool = False) list[LeadershipSchedule][source]
Get the slots the node is expected to mint a block in.
- Parameters:
vrf_skey_file – A path to node VRF skey file.
stake_pool_vkey – A pool cold vkey (Bech32 or hex-encoded, optional)
cold_vkey_file – A path to pool cold vkey file (optional).
stake_pool_id – An ID of the stake pool (Bech32 or hex-encoded, optional).
for_next – A bool indicating whether to get the leadership schedule for the following epoch (current epoch by default)
- Returns:
- A list of structs.LeadershipSchedule, specifying
slot and time.
- Return type:
- get_mempool_info() dict[str, Any][source]
Return info about the current mempool’s capacity and sizes.
- Returns:
A dictionary containing mempool information.
- Return type:
dict
- get_mempool_next_tx() dict[str, Any][source]
Return info about the next transaction in the mempool’s current list.
- Returns:
A dictionary containing mempool information.
- Return type:
dict
- get_mempool_tx_exists(txid: str) dict[str, Any][source]
Query if a particular transaction exists in the mempool.
- Parameters:
txid – A transaction ID.
- Returns:
A dictionary containing mempool information.
- Return type:
dict
- get_pool_deposit(pparams: dict[str, Any] | None = None) int[source]
Return stake pool deposit amount.
- get_pool_params(stake_pool_id: str) PoolParamsTop[source]
Return a pool parameters.
- Parameters:
stake_pool_id – An ID of the stake pool (Bech32-encoded or hex-encoded).
- Returns:
A pool parameters.
- Return type:
dict
- get_pool_state(stake_pool_id: str) PoolParamsTop[source]
Return a pool state.
- Parameters:
stake_pool_id – An ID of the stake pool (Bech32-encoded or hex-encoded).
- Returns:
A pool parameters.
- Return type:
dict
- get_proposals(action_txid: str = '', action_ix: int | None = None) list[dict[str, Any]][source]
Get the governance proposals that are eligible for ratification.
When no arguments are passed, query for all proposals.
- Parameters:
action_txid – TxId of the governance action.
action_ix – Tx’s governance action index.
- Returns:
A list of governance proposals.
- Return type:
list[dict[str, tp.Any]]
- get_ref_script_size(txin: str | list[str] = '', utxo: UTXOData | list[UTXOData] | tuple[()] = ()) dict[str, Any][source]
Get the reference input script size in bytes for one or more transaction inputs.
- Parameters:
txin – One or more transaction inputs in the format ‘TxId#TxIx’ (string or list of strings).
utxo – One or more UTxO records (structs.UTXOData) or an empty tuple by default.
- Returns:
- JSON output from the CLI, typically containing
keys like ‘refScriptSize’ or ‘refInputScriptSize’.
- Return type:
dict[str, Any]
- get_registered_stake_pools_ledger_state() dict[source]
Return ledger state info for registered stake pools.
- get_slot_no(tip: dict[str, Any] | None = None) int[source]
Return slot number of last block that was successfully applied to the ledger.
- get_slots_to_epoch_end(tip: dict[str, Any] | None = None) int[source]
Return the number of slots left until the epoch end.
- get_spo_stake_distribution(spo_vkey: str = '', spo_vkey_file: str | Path | None = None, spo_key_hash: str = '') list[SPOStakeDistrib][source]
Get the SPO stake distribution.
When no key is provided, query all SPOs.
- Parameters:
spo_vkey – SPO verification key (Bech32 or hex-encoded).
spo_vkey_file – Filepath of the SPO verification key.
spo_key_hash – SPO verification key hash (either Bech32-encoded or hex-encoded).
- Returns:
SPO stake distribution.
- Return type:
list[structs.SPOStakeDistrib]
- get_stake_addr_info(stake_addr: str) StakeAddrInfo[source]
Return the current delegations and reward accounts filtered by stake address.
- Parameters:
stake_addr – A stake address string.
- Returns:
A data container containing stake address info.
- Return type:
- get_stake_distribution() dict[str, float][source]
Return current aggregated stake distribution per stake pool.
- get_stake_pool_default_vote(spo_vkey: str = '', spo_vkey_file: str | Path | None = None, spo_key_hash: str = '') str[source]
Get the stake pool default vote.
- get_stake_snapshot(stake_pool_ids: list[str] | None = None, all_stake_pools: bool = False) dict[str, Any][source]
Return the three stake snapshots, plus the total active stake.
- Parameters:
stake_pool_ids – A list of stake pool IDs, Bech32-encoded or hex-encoded (optional).
all_stake_pools – A bool indicating whether to query for all stake pools (optional).
- Returns:
A stake snapshot data.
- Return type:
dict
- get_tip() dict[str, Any][source]
Return current tip - last block successfully applied to the ledger.
- get_utxo(address: str | list[str] = '', txin: str | list[str] = '', utxo: UTXOData | list[UTXOData] | tuple[()] = (), tx_raw_output: TxRawOutput | None = None, coins: list | tuple | set | frozenset = ()) list[UTXOData][source]
Return UTxO info for payment address.
- Parameters:
address – Payment address(es).
txin – Transaction input(s) (TxId#TxIx).
utxo – Representation of UTxO data (structs.UTXOData).
tx_raw_output – A data used when building a transaction (structs.TxRawOutput).
coins – A list (iterable) of coin names (asset IDs, optional).
- Returns:
A list of UTxO data.
- Return type:
list[structs.UTXOData]
- get_utxo_with_highest_amount(address: str, coin: str = 'lovelace') UTXOData[source]
Return data for UTxO with the highest amount.
- Parameters:
address – A payment address string.
coin – A coin name (asset IDs).
- Returns:
A UTxO record with the highest amount.
- Return type:
- query_cli(cli_args: list | tuple | set | frozenset, cli_sub_args: list | tuple | set | frozenset = ()) str[source]
Run the cardano-cli query command.
- save_ledger_state(state_name: str, destination_dir: str | Path = '.') Path[source]
Save ledger state to file.
- Parameters:
state_name – A name of the ledger state (can be epoch number, etc.).
destination_dir – A path to directory for storing the state JSON file (optional).
- Returns:
A path to the generated state JSON file.
- Return type:
Path
cardano_clusterlib.stake_address_group module
Group of methods for working with stake addresses.
- class cardano_clusterlib.stake_address_group.StakeAddressGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- gen_stake_addr(addr_name: str, stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, destination_dir: str | Path = '.') str[source]
Generate a stake address.
- Parameters:
addr_name – A name of payment address.
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding payment script file (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A generated stake address.
- Return type:
str
- gen_stake_addr_and_keys(name: str, destination_dir: str | Path = '.') AddressRecord[source]
Generate stake address and key pair.
- Parameters:
name – A name of the address and key pair.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
- A data container containing the address
and key pair / script file.
- Return type:
- gen_stake_addr_delegation_cert(addr_name: str, stake_vkey: str = '', stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, stake_pool_vkey: str = '', cold_vkey_file: str | Path | None = None, stake_pool_id: str = '', destination_dir: str | Path = '.') Path[source]
Generate a stake address delegation certificate.
- Parameters:
addr_name – A name of stake address.
stake_vkey – A stake vkey file (optional).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – Stake address key, bech32 or hex-encoded (optional).
stake_pool_vkey – A stake pool verification key (Bech32 or hex-encoded, optional).
cold_vkey_file – A path to pool cold vkey file (optional).
stake_pool_id – An ID of the stake pool (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_stake_addr_deregistration_cert(addr_name: str, deposit_amt: int = -1, stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, destination_dir: str | Path = '.') Path[source]
Generate a stake address deregistration certificate.
- Parameters:
addr_name – A name of stake address.
deposit_amt – A stake address registration deposit amount (required in Conway+).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – Stake address key, bech32 or hex-encoded (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_stake_addr_registration_cert(addr_name: str, deposit_amt: int = -1, stake_vkey: str = '', stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, destination_dir: str | Path = '.') Path[source]
Generate a stake address registration certificate.
- Parameters:
addr_name – A name of stake address.
deposit_amt – A stake address registration deposit amount (required in Conway+).
stake_vkey – A stake vkey file (optional).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – Stake address key, bech32 or hex-encoded (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_stake_and_vote_delegation_cert(addr_name: str, stake_vkey: str = '', stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, stake_pool_vkey: str = '', cold_vkey_file: str | Path | None = None, stake_pool_id: str = '', drep_script_hash: str = '', drep_vkey: str = '', drep_vkey_file: str | Path | None = None, drep_key_hash: str = '', always_abstain: bool = False, always_no_confidence: bool = False, destination_dir: str | Path = '.') Path[source]
Generate a stake address stake and vote delegation certificate.
- Parameters:
addr_name – A name of stake address.
stake_vkey – A stake vkey file (optional).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – Stake address key, bech32 or hex-encoded (optional).
stake_pool_vkey – A stake pool verification key (Bech32 or hex-encoded, optional).
cold_vkey_file – A path to pool cold vkey file (optional).
stake_pool_id – An ID of the stake pool (optional). (either Bech32-encoded or hex-encoded, optional).
drep_script_hash – DRep script hash (hex-encoded, optional).
drep_vkey – DRep verification key (Bech32 or hex-encoded, optional).
drep_vkey_file – Filepath of the DRep verification key (optional).
drep_key_hash – DRep verification key hash
always_abstain – A bool indicating whether to delegate to always-abstain DRep (optional).
always_no_confidence – A bool indicating whether to delegate to always-vote-no-confidence DRep (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_stake_key_pair(key_name: str, destination_dir: str | Path = '.') KeyPair[source]
Generate a stake address key pair.
- Parameters:
key_name – A name of the key pair.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing the key pair.
- Return type:
- gen_vote_delegation_cert(addr_name: str, stake_vkey: str = '', stake_vkey_file: str | Path | None = None, stake_script_file: str | Path | None = None, stake_address: str | None = None, drep_script_hash: str = '', drep_vkey: str = '', drep_vkey_file: str | Path | None = None, drep_key_hash: str = '', always_abstain: bool = False, always_no_confidence: bool = False, destination_dir: str | Path = '.') Path[source]
Generate a stake address vote delegation certificate.
- Parameters:
addr_name – A name of stake address.
stake_vkey – A stake vkey file (optional).
stake_vkey_file – A path to corresponding stake vkey file (optional).
stake_script_file – A path to corresponding stake script file (optional).
stake_address – Stake address key, bech32 or hex-encoded (optional).
drep_script_hash – DRep script hash (hex-encoded, optional).
drep_vkey – DRep verification key (Bech32 or hex-encoded, optional).
drep_vkey_file – Filepath of the DRep verification key (optional).
drep_key_hash – DRep verification key hash (either Bech32-encoded or hex-encoded, optional).
always_abstain – A bool indicating whether to delegate to always-abstain DRep (optional).
always_no_confidence – A bool indicating whether to delegate to always-vote-no-confidence DRep (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- get_stake_vkey_hash(stake_vkey_file: str | Path | None = None, stake_vkey: str | None = None) str[source]
Return the hash of a stake address key.
- Parameters:
stake_vkey_file – A path to stake vkey file (optional).
stake_vkey – A stake vkey (Bech32, optional).
- Returns:
A generated hash.
- Return type:
str
- withdraw_reward(stake_addr_record: AddressRecord, dst_addr_record: AddressRecord, tx_name: str, verify: bool = True, destination_dir: str | Path = '.') TxRawOutput[source]
Withdraw reward to payment address.
- Parameters:
stake_addr_record – A structs.AddressRecord data container for the stake address with reward.
dst_addr_record – A structs.AddressRecord data container for the destination payment address.
tx_name – A name of the transaction.
verify – A bool indicating whether to verify that the reward was transferred correctly.
destination_dir – A path to directory for storing artifacts (optional).
cardano_clusterlib.stake_pool_group module
Group of methods for working with stake pools.
- class cardano_clusterlib.stake_pool_group.StakePoolGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- create_stake_pool(pool_data: PoolData, pool_owners: list[PoolUser], tx_name: str, reward_account_key_pair: KeyPair | AddressRecord | None = None, destination_dir: str | Path = '.') PoolCreationOutput[source]
Create and register a stake pool.
- Parameters:
pool_data – A structs.PoolData data container containing info about the stake pool.
pool_owners – A list of structs.PoolUser structures containing pool user addresses and keys.
tx_name – A name of the transaction.
reward_account_key_pair – A data container containing reward account key pair (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container containing pool creation output.
- Return type:
- deregister_stake_pool(pool_owners: list[PoolUser], cold_key_pair: ColdKeyPair, epoch: int, pool_name: str, tx_name: str, destination_dir: str | Path = '.') tuple[Path, TxRawOutput][source]
Deregister a stake pool.
- Parameters:
pool_owners – A list of structs.PoolUser structures containing pool user addresses and keys.
cold_key_pair – A structs.ColdKeyPair data container containing the key pair and the counter.
epoch – An epoch where the update proposal will take effect (optional).
pool_name – A name of the stake pool.
tx_name – A name of the transaction.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
- A data container with pool registration cert file and
transaction output details.
- Return type:
tuple[Path, structs.TxRawOutput]
- gen_pool_deregistration_cert(pool_name: str, cold_vkey_file: str | Path, epoch: int, destination_dir: str | Path = '.') Path[source]
Generate a stake pool deregistration certificate.
- Parameters:
pool_name – A name of the stake pool.
cold_vkey_file – A path to pool cold vkey file.
epoch – An epoch where the pool will be deregistered.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- gen_pool_metadata_hash(pool_metadata_file: str | Path) str[source]
Generate the hash of pool metadata.
- Parameters:
pool_metadata_file – A path to the pool metadata file.
- Returns:
A metadata hash.
- Return type:
str
- gen_pool_registration_cert(pool_data: PoolData, vrf_vkey_file: str | Path, cold_vkey_file: str | Path, owner_stake_vkey_files: list[str | Path] | list[str] | list[Path], reward_account_vkey_file: str | Path | None = None, destination_dir: str | Path = '.') Path[source]
Generate a stake pool registration certificate.
- Parameters:
pool_data – A structs.PoolData data container containing info about the stake pool.
vrf_vkey_file – A path to node VRF vkey file.
cold_vkey_file – A path to pool cold vkey file.
owner_stake_vkey_files – A list of paths to pool owner stake vkey files.
reward_account_vkey_file – A path to pool reward account vkey file (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the generated certificate.
- Return type:
Path
- get_stake_pool_id(cold_vkey_file: str | Path | None = None, stake_pool_vkey: str = '') str[source]
Return pool ID from the offline key.
- Parameters:
cold_vkey_file – A path to pool cold vkey file.
stake_pool_vkey – A stake pool verification key (Bech32 or hex-encoded).
- Returns:
A pool ID.
- Return type:
str
- register_stake_pool(pool_data: PoolData, pool_owners: list[PoolUser], vrf_vkey_file: str | Path, cold_key_pair: ColdKeyPair, tx_name: str, reward_account_vkey_file: str | Path | None = None, deposit: int | None = None, destination_dir: str | Path = '.') tuple[Path, TxRawOutput][source]
Register a stake pool.
- Parameters:
pool_data – A structs.PoolData data container containing info about the stake pool.
pool_owners – A list of structs.PoolUser structures containing pool user addresses and keys.
vrf_vkey_file – A path to node VRF vkey file.
cold_key_pair – A structs.ColdKeyPair data container containing the key pair and the counter.
tx_name – A name of the transaction.
reward_account_vkey_file – A path to reward account vkey file (optional).
deposit – A deposit amount needed by the transaction (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
- A tuple with pool registration cert file and
transaction output details.
- Return type:
tuple[Path, structs.TxRawOutput]
cardano_clusterlib.structs module
- class cardano_clusterlib.structs.ActionConstitution(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, constitution_url: str, constitution_hash: str, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '', prev_action_txid: str = '', prev_action_ix: int = -1)[source]
Bases:
object
- class cardano_clusterlib.structs.ActionHardfork(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, protocol_major_version: int, protocol_minor_version: int, prev_action_txid: str = '', prev_action_ix: int = -1, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ActionInfo(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ActionNoConfidence(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, prev_action_txid: str, prev_action_ix: int, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ActionPParamsUpdate(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, cli_args: list | tuple | set | frozenset, prev_action_txid: str = '', prev_action_ix: int = -1, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ActionTreasuryWithdrawal(action_file: pathlib.Path, transfer_amt: int, deposit_amt: int, anchor_url: str, anchor_data_hash: str, funds_receiving_stake_vkey: str = '', funds_receiving_stake_vkey_file: pathlib.Path | None = None, funds_receiving_stake_key_hash: str = '', deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ActionUpdateCommittee(action_file: pathlib.Path, deposit_amt: int, anchor_url: str, anchor_data_hash: str, threshold: str, add_cc_members: list[cardano_clusterlib.structs.CCMember] = <factory>, rem_cc_members: list[cardano_clusterlib.structs.CCMember] = <factory>, prev_action_txid: str = '', prev_action_ix: int = -1, deposit_return_stake_vkey: str = '', deposit_return_stake_vkey_file: pathlib.Path | None = None, deposit_return_stake_key_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.AddressInfo(address: str, era: str, encoding: str, type: str, base16: str)[source]
Bases:
object
- class cardano_clusterlib.structs.AddressRecord(address: str, vkey_file: pathlib.Path, skey_file: pathlib.Path)[source]
Bases:
object
- class cardano_clusterlib.structs.CCMember(epoch: int, cold_vkey: str = '', cold_vkey_file: str | pathlib.Path = '', cold_vkey_hash: str = '', cold_skey: str = '', cold_skey_file: str | pathlib.Path = '', cold_skey_hash: str = '', cold_script_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.ColdKeyPair(vkey_file: pathlib.Path, skey_file: pathlib.Path, counter_file: pathlib.Path)[source]
Bases:
object
- class cardano_clusterlib.structs.ComplexCert(certificate_file: str | Path, script_file: str | Path = '', reference_txin: UTXOData | None = None, reference_type: str = '', collaterals: list[UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, redeemer_file: str | Path = '', redeemer_cbor_file: str | Path = '', redeemer_value: str = '')[source]
Bases:
objectData structure for certificates with optional data for Plutus scripts.
If used for one certificate, it needs to be used for all the other certificates in a given transaction (instead of TxFiles.certificate_files). Otherwise, order of certificates cannot be guaranteed.
- class cardano_clusterlib.structs.ComplexProposal(proposal_file: str | Path, script_file: str | Path = '', collaterals: list[UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, redeemer_file: str | Path = '', redeemer_cbor_file: str | Path = '', redeemer_value: str = '')[source]
Bases:
objectData structure for proposal with optional data for Plutus scripts.
If used for one proposal, it needs to be used for all the other proposals in a given transaction (instead of TxFiles.proposal_files). Otherwise, order of proposals cannot be guaranteed.
- class cardano_clusterlib.structs.DataForBuild(txins: list[cardano_clusterlib.structs.UTXOData], txouts: list[cardano_clusterlib.structs.TxOut], withdrawals: list[cardano_clusterlib.structs.TxOut] | tuple[()], script_withdrawals: list[cardano_clusterlib.structs.ScriptWithdrawal] | tuple[()])[source]
Bases:
object- script_withdrawals: list[ScriptWithdrawal] | tuple[()][source]
- class cardano_clusterlib.structs.GenesisKeys(genesis_utxo_vkey: pathlib.Path, genesis_utxo_skey: pathlib.Path, genesis_vkeys: list[pathlib.Path], delegate_skeys: list[pathlib.Path])[source]
Bases:
object
- class cardano_clusterlib.structs.KeyPair(vkey_file: pathlib.Path, skey_file: pathlib.Path)[source]
Bases:
object
- class cardano_clusterlib.structs.LeadershipSchedule(slot_no: int, utc_time: datetime.datetime)[source]
Bases:
object
- class cardano_clusterlib.structs.Mint(txouts: list[cardano_clusterlib.structs.TxOut], script_file: str | pathlib.Path = '', reference_txin: cardano_clusterlib.structs.UTXOData | None = None, reference_type: str = '', policyid: str = '', collaterals: list[cardano_clusterlib.structs.UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, redeemer_file: str | pathlib.Path = '', redeemer_cbor_file: str | pathlib.Path = '', redeemer_value: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.PoolCreationOutput(stake_pool_id: str, vrf_key_pair: cardano_clusterlib.structs.KeyPair, cold_key_pair: cardano_clusterlib.structs.ColdKeyPair, pool_reg_cert_file: pathlib.Path, pool_data: cardano_clusterlib.structs.PoolData, pool_owners: list[cardano_clusterlib.structs.PoolUser], reward_account_key_pair: cardano_clusterlib.structs.KeyPair | cardano_clusterlib.structs.AddressRecord, tx_raw_output: cardano_clusterlib.structs.TxRawOutput, kes_key_pair: cardano_clusterlib.structs.KeyPair | None = None)[source]
Bases:
object- cold_key_pair: ColdKeyPair[source]
- reward_account_key_pair: KeyPair | AddressRecord[source]
- tx_raw_output: TxRawOutput[source]
- class cardano_clusterlib.structs.PoolData(pool_name: str, pool_pledge: int, pool_cost: int, pool_margin: float, pool_metadata_url: str = '', pool_metadata_hash: str = '', pool_relay_dns: str = '', pool_relay_ipv4: str = '', pool_relay_port: int = 0)[source]
Bases:
object
- class cardano_clusterlib.structs.PoolParamsTop(pool_params: dict, future_pool_params: dict, retiring: int | None)[source]
Bases:
object
- class cardano_clusterlib.structs.PoolUser(payment: cardano_clusterlib.structs.AddressRecord, stake: cardano_clusterlib.structs.AddressRecord)[source]
Bases:
object- payment: AddressRecord[source]
- stake: AddressRecord[source]
- class cardano_clusterlib.structs.SPOStakeDistrib(spo_vkey_hex: str, stake_distribution: int, vote_delegation: str)[source]
Bases:
object
- class cardano_clusterlib.structs.ScriptTxIn(txins: list[UTXOData], script_file: str | Path = '', reference_txin: UTXOData | None = None, reference_type: str = '', collaterals: list[UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, datum_file: str | Path = '', datum_cbor_file: str | Path = '', datum_value: str = '', inline_datum_present: bool = False, redeemer_file: str | Path = '', redeemer_cbor_file: str | Path = '', redeemer_value: str = '')[source]
Bases:
objectData structure for Tx inputs that are combined with scripts (simple or Plutus).
- class cardano_clusterlib.structs.ScriptVote(vote_file: str | Path = '', script_file: str | Path = '', collaterals: list[UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, redeemer_file: str | Path = '', redeemer_cbor_file: str | Path = '', redeemer_value: str = '')[source]
Bases:
objectData structure for voting that are combined with scripts.
- class cardano_clusterlib.structs.ScriptWithdrawal(txout: TxOut, script_file: str | Path = '', reference_txin: UTXOData | None = None, reference_type: str = '', collaterals: list[UTXOData] | tuple[()] = (), execution_units: tuple[int, int] | None = None, redeemer_file: str | Path = '', redeemer_cbor_file: str | Path = '', redeemer_value: str = '')[source]
Bases:
objectData structure for withdrawals that are combined with Plutus scripts.
- class cardano_clusterlib.structs.StakeAddrInfo(address: str, delegation: str, reward_account_balance: int, registration_deposit: int, vote_delegation: str, delegation_hex: str = '', vote_delegation_hex: str = '', vote_delegation_cip129_hex: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.TxFiles(certificate_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), proposal_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), metadata_json_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), metadata_cbor_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), signing_key_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), auxiliary_script_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), vote_files: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), metadata_json_detailed_schema: bool = False)[source]
Bases:
object
- class cardano_clusterlib.structs.TxOut(address: str, amount: int, coin: str = 'lovelace', datum_hash: str = '', datum_hash_file: str | pathlib.Path = '', datum_hash_cbor_file: str | pathlib.Path = '', datum_hash_value: str = '', datum_embed_file: str | pathlib.Path = '', datum_embed_cbor_file: str | pathlib.Path = '', datum_embed_value: str = '', inline_datum_file: str | pathlib.Path = '', inline_datum_cbor_file: str | pathlib.Path = '', inline_datum_value: str = '', reference_script_file: str | pathlib.Path = '')[source]
Bases:
object
- class cardano_clusterlib.structs.TxRawOutput(txins: list[cardano_clusterlib.structs.UTXOData], txouts: list[cardano_clusterlib.structs.TxOut], txouts_count: int, tx_files: cardano_clusterlib.structs.TxFiles, out_file: pathlib.Path, fee: int, build_args: list[str], era: str = '', script_txins: list[cardano_clusterlib.structs.ScriptTxIn] | tuple[()] = (), script_withdrawals: list[cardano_clusterlib.structs.ScriptWithdrawal] | tuple[()] = (), script_votes: list[cardano_clusterlib.structs.ScriptVote] | tuple[()] = (), complex_certs: list[cardano_clusterlib.structs.ComplexCert] | tuple[()] = (), complex_proposals: list[cardano_clusterlib.structs.ComplexProposal] | tuple[()] = (), mint: list[cardano_clusterlib.structs.Mint] | tuple[()] = (), invalid_hereafter: int | None = None, invalid_before: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, withdrawals: list[cardano_clusterlib.structs.TxOut] | tuple[()] = (), change_address: str = '', return_collateral_txouts: list[cardano_clusterlib.structs.TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, readonly_reference_txins: list[cardano_clusterlib.structs.UTXOData] | tuple[()] = (), script_valid: bool = True, required_signers: list[str | pathlib.Path] | list[str] | list[pathlib.Path] | tuple[()] = (), required_signer_hashes: list[str] | tuple[()] = (), combined_reference_txins: list[cardano_clusterlib.structs.UTXOData] | tuple[()] = ())[source]
Bases:
object- complex_certs: list[ComplexCert] | tuple[()] = ()[source]
- complex_proposals: list[ComplexProposal] | tuple[()] = ()[source]
- script_txins: list[ScriptTxIn] | tuple[()] = ()[source]
- script_votes: list[ScriptVote] | tuple[()] = ()[source]
- script_withdrawals: list[ScriptWithdrawal] | tuple[()] = ()[source]
- class cardano_clusterlib.structs.UTXOData(utxo_hash: str, utxo_ix: int, amount: int, address: str, coin: str = 'lovelace', decoded_coin: str = '', datum_hash: str = '', inline_datum_hash: str = '', inline_datum: str | dict | None = None, reference_script: dict | None = None)[source]
Bases:
object
- class cardano_clusterlib.structs.VoteCC(action_txid: str, action_ix: int, vote: cardano_clusterlib.consts.Votes, vote_file: pathlib.Path, cc_hot_vkey: str = '', cc_hot_vkey_file: pathlib.Path | None = None, cc_hot_key_hash: str = '', cc_hot_script_hash: str = '', anchor_url: str = '', anchor_data_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.VoteDrep(action_txid: str, action_ix: int, vote: cardano_clusterlib.consts.Votes, vote_file: pathlib.Path, drep_vkey: str = '', drep_vkey_file: pathlib.Path | None = None, drep_key_hash: str = '', drep_script_hash: str = '', anchor_url: str = '', anchor_data_hash: str = '')[source]
Bases:
object
- class cardano_clusterlib.structs.VoteSPO(action_txid: str, action_ix: int, vote: cardano_clusterlib.consts.Votes, vote_file: pathlib.Path, stake_pool_vkey: str = '', cold_vkey_file: pathlib.Path | None = None, stake_pool_id: str = '', anchor_url: str = '', anchor_data_hash: str = '')[source]
Bases:
object
cardano_clusterlib.transaction_group module
Group of methods for working with transactions.
- class cardano_clusterlib.transaction_group.TransactionGroup(clusterlib_obj: itp.ClusterLib)[source]
Bases:
object- assemble_tx(tx_body_file: str | Path, witness_files: list[str | Path] | list[str] | list[Path] | tuple[()], tx_name: str, destination_dir: str | Path = '.') Path[source]
Assemble a tx body and witness(es) to form a signed transaction.
- Parameters:
tx_body_file – A path to file with transaction body.
witness_files – A list of paths to transaction witness files.
tx_name – A name of the transaction.
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to signed transaction file.
- Return type:
Path
- build_estimate_tx(src_address: str, tx_name: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), change_address: str = '', fee_buffer: int | None = None, required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, script_valid: bool = True, src_addr_utxos: list[UTXOData] | None = None, witness_count_add: int = 0, byron_witness_count: int = 0, reference_script_size: int = 0, join_txouts: bool = True, destination_dir: str | Path = '.', skip_asset_balancing: bool = True) TxRawOutput[source]
Build a balanced transaction without access to a live node.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposals script data (optional).
change_address – A string with address where ADA in excess of the transaction fee will go to (src_address by default).
fee_buffer – A buffer for fee amount (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
current_treasury_value – The current treasury value (optional).
treasury_donation – A donation to the treasury to perform (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
script_valid – A bool indicating that the script is valid (True by default).
src_addr_utxos – A list of UTxOs for the source address (optional).
witness_count_add – A number of witnesses to add - workaround to make the fee calculation more precise.
byron_witness_count – A number of Byron witnesses (optional).
reference_script_size – A size in bytes of transaction reference scripts (optional).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
destination_dir – A path to directory for storing artifacts (optional).
skip_asset_balancing – A bool indicating if assets balancing should be skipped.
- Returns:
A data container with transaction output details.
- Return type:
- build_multisig_script(script_name: str, script_type_arg: str, payment_vkey_files: list[str | Path] | list[str] | list[Path] | tuple[()], required: int = 0, slot: int = 0, slot_type_arg: str = '', destination_dir: str | Path = '.') Path[source]
Build a multi-signature script.
- Parameters:
script_name – A name of the script.
script_type_arg – A script type, see MultiSigTypeArgs.
payment_vkey_files – A list of paths to payment vkey files.
required – A number of required keys for the “atLeast” script type (optional).
slot – A slot that sets script validity, depending on value of slot_type_arg (optional).
slot_type_arg – A slot validity type, see MultiSlotTypeArgs (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to the script file.
- Return type:
Path
- build_raw_tx(src_address: str, tx_name: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), fee: int = 0, required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, ttl: int | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, script_valid: bool = True, src_addr_utxos: list[UTXOData] | None = None, join_txouts: bool = True, destination_dir: str | Path = '.') TxRawOutput[source]
Balance inputs and outputs and build a raw transaction.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposals script data (optional).
fee – A fee amount (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
ttl – A last block when the transaction is still valid (deprecated in favor of invalid_hereafter, optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
current_treasury_value – The current treasury value (optional).
treasury_donation – A donation to the treasury to perform (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
script_valid – A bool indicating that the script is valid (True by default).
src_addr_utxos – A list of UTxOs for the source address (optional).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container with transaction output details.
- Return type:
- build_raw_tx_bare(out_file: str | Path, txouts: list[TxOut], tx_files: TxFiles, fee: int, txins: list[UTXOData] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, ttl: int | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), invalid_hereafter: int | None = None, invalid_before: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, script_valid: bool = True, join_txouts: bool = True) TxRawOutput[source]
Build a raw transaction.
- Parameters:
out_file – An output file.
txouts – A list (iterable) of TxOuts, specifying transaction outputs.
tx_files – A structs.TxFiles data container containing files needed for the transaction.
fee – A fee amount.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposal script data (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
ttl – A last block when the transaction is still valid (deprecated in favor of invalid_hereafter, optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
current_treasury_value – The current treasury value (optional).
treasury_donation – A donation to the treasury to perform (optional).
script_valid – A bool indicating that the script is valid (True by default).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
- Returns:
A data container with transaction output details.
- Return type:
- build_tx(src_address: str, tx_name: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), change_address: str = '', fee_buffer: int | None = None, required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, treasury_donation: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, witness_override: int | None = None, script_valid: bool = True, calc_script_cost_file: str | Path | None = None, join_txouts: bool = True, destination_dir: str | Path = '.', skip_asset_balancing: bool = True) TxRawOutput[source]
Build a transaction.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposal script data (optional).
change_address – A string with address where ADA in excess of the transaction fee will go to (src_address by default).
fee_buffer – A buffer for fee amount (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
treasury_donation – A donation to the treasury to perform (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
witness_override – An integer indicating real number of witnesses. Can be used to fix fee calculation (optional).
script_valid – A bool indicating that the script is valid (True by default).
calc_script_cost_file – A path for output of the Plutus script cost information (optional).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
destination_dir – A path to directory for storing artifacts (optional).
skip_asset_balancing – A bool indicating if assets balancing should be skipped (build command balance the assets automatically in newer versions).
- Returns:
A data container with transaction output details.
- Return type:
- calculate_min_req_utxo(txouts: list[TxOut]) Value[source]
Calculate the minimum required UTxO for a single transaction output.
- Parameters:
txouts – A list of TxOut records that correspond to a single transaction output (UTxO).
- Returns:
A data container describing the value.
- Return type:
- calculate_plutus_script_cost(src_address: str, tx_name: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), change_address: str = '', fee_buffer: int | None = None, required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, witness_override: int | None = None, script_valid: bool = True, calc_script_cost_file: str | Path | None = None, join_txouts: bool = True, destination_dir: str | Path = '.') list[dict][source]
Calculate cost of Plutus scripts. Accepts the same arguments as build_tx.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposal script data (optional).
change_address – A string with address where ADA in excess of the transaction fee will go to (src_address by default).
fee_buffer – A buffer for fee amount (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
witness_override – An integer indicating real number of witnesses. Can be used to fix fee calculation (optional).
script_valid – A bool indicating that the script is valid (True by default).
calc_script_cost_file – A path for output of the Plutus script cost information (optional).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A Plutus scripts cost data.
- Return type:
list[dict]
- calculate_tx_fee(src_address: str, tx_name: str, dst_addresses: list[str] | None = None, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, ttl: int | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, src_addr_utxos: list[UTXOData] | None = None, witness_count_add: int = 0, byron_witness_count: int = 0, reference_script_size: int = 0, join_txouts: bool = True, destination_dir: str | Path = '.') int[source]
Build “dummy” transaction and calculate (estimate) its fee.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
dst_addresses – A list of destination addresses (optional)
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposal script data (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
ttl – A last block when the transaction is still valid (deprecated in favor of invalid_hereafter, optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
current_treasury_value – The current treasury value (optional).
treasury_donation – A donation to the treasury to perform (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
src_addr_utxos – A list of UTxOs for the source address (optional).
witness_count_add – A number of witnesses to add - workaround to make the fee calculation more precise.
byron_witness_count – A number of Byron witnesses (optional).
reference_script_size – A size in bytes of transaction reference scripts (optional).
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
An estimated fee.
- Return type:
int
- estimate_fee(txbody_file: str | Path, txin_count: int, txout_count: int, witness_count: int, byron_witness_count: int = 0, reference_script_size: int = 0) int[source]
Estimate the minimum fee for a transaction.
- Parameters:
txbody_file – A path to file with transaction body.
txin_count – A number of transaction inputs.
txout_count – A number of transaction outputs.
witness_count – A number of witnesses.
byron_witness_count – A number of Byron witnesses (optional).
reference_script_size – A size in bytes of transaction reference scripts (optional).
- Returns:
An estimated fee.
- Return type:
int
- get_hash_script_data(script_data_file: str | Path | None = None, script_data_cbor_file: str | Path | None = None, script_data_value: str = '') str[source]
Return the hash of script data.
- Parameters:
script_data_file – A path to the JSON file containing the script data (optional).
script_data_cbor_file – A path to the CBOR file containing the script data (optional).
script_data_value – A value (in JSON syntax) for the script data (optional).
- Returns:
A hash of script data.
- Return type:
str
- get_policyid(script_file: str | Path) str[source]
Calculate the PolicyId from the monetary policy script.
- Parameters:
script_file – A path to the script file.
- Returns:
A script policyId.
- Return type:
str
- get_tx_deposit(tx_files: TxFiles) int[source]
Get deposit amount for a transaction (based on certificates used for the TX).
- Parameters:
tx_files – A structs.TxFiles data container containing files needed for the transaction.
- Returns:
A total deposit amount needed for the transaction.
- Return type:
int
- get_txid(tx_body_file: str | Path = '', tx_file: str | Path = '') str[source]
Return the transaction identifier.
- Parameters:
tx_body_file – A path to the transaction body file (JSON TxBody - optional).
tx_file – A path to the signed transaction file (JSON Tx - optional).
- Returns:
A transaction ID.
- Return type:
str
- send_tx(src_address: str, tx_name: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), readonly_reference_txins: list[UTXOData] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), return_collateral_txouts: list[TxOut] | tuple[()] = (), total_collateral_amount: int | None = None, mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), fee: int | None = None, required_signers: list[str | Path] | list[str] | list[Path] | tuple[()] = (), required_signer_hashes: list[str] | None = None, ttl: int | None = None, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), script_votes: list[ScriptVote] | tuple[()] = (), deposit: int | None = None, current_treasury_value: int | None = None, treasury_donation: int | None = None, invalid_hereafter: int | None = None, invalid_before: int | None = None, witness_count_add: int = 0, join_txouts: bool = True, verify_tx: bool = True, destination_dir: str | Path = '.') TxRawOutput[source]
Build, Sign and Submit a transaction.
Not recommended for complex transactions that involve Plutus scripts!
This function uses cardano-cli transaction build-raw to build the transaction. For more complex transactions that involve Plutus scripts, consider using build_tx. The build_tx uses cardano-cli transaction build and handles execution units and collateral return automatically.
- Parameters:
src_address – An address used for fee and inputs (if inputs not specified by txins).
tx_name – A name of the transaction.
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
readonly_reference_txins – An iterable of structs.UTXOData, specifying input UTxOs to be referenced and used as readonly (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
return_collateral_txouts – A list (iterable) of TxOuts, specifying transaction outputs for excess collateral (optional).
total_collateral_amount – An integer indicating the total amount of collateral (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposal script data (optional).
fee – A fee amount (optional).
required_signers – An iterable of filepaths of the signing keys whose signatures are required (optional).
required_signer_hashes – A list of hashes of the signing keys whose signatures are required (optional).
ttl – A last block when the transaction is still valid (deprecated in favor of invalid_hereafter, optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
script_votes – An iterable of ScriptVote, specifying vote script data (optional).
deposit – A deposit amount needed by the transaction (optional).
current_treasury_value – The current treasury value (optional).
treasury_donation – A donation to the treasury to perform (optional).
invalid_hereafter – A last block when the transaction is still valid (optional).
invalid_before – A first block when the transaction is valid (optional).
witness_count_add – A number of witnesses to add - workaround to make the fee calculation more precise.
join_txouts – A bool indicating whether to aggregate transaction outputs by payment address (True by default).
verify_tx – A bool indicating whether to verify the transaction made it to chain and resubmit the transaction if not (True by default).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A data container with transaction output details.
- Return type:
- sign_tx(signing_key_files: list[str | Path] | list[str] | list[Path] | tuple[()], tx_name: str, tx_body_file: str | Path | None = None, tx_file: str | Path | None = None, destination_dir: str | Path = '.') Path[source]
Sign a transaction.
- Parameters:
signing_key_files – A list of paths to signing key files.
tx_name – A name of the transaction.
tx_body_file – A path to file with transaction body (optional).
tx_file – A path to file with transaction (for incremental signing, optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to signed transaction file.
- Return type:
Path
- submit_tx(tx_file: str | Path, txins: list[UTXOData], wait_blocks: int | None = None) str[source]
Submit a transaction, resubmit if the transaction didn’t make it to the chain.
- Parameters:
tx_file – A path to signed transaction file.
txins – An iterable of structs.UTXOData, specifying input UTxOs.
wait_blocks – A number of new blocks to wait for (default = 2).
- Returns:
A transaction ID.
- Return type:
str
- submit_tx_bare(tx_file: str | Path) str[source]
Submit a transaction to a mempool.
Doesn’t do any verification that the transaction made it to the chain.
- Parameters:
tx_file – A path to signed transaction file.
- Returns:
A transaction ID.
- Return type:
str
- view_tx(tx_body_file: str | Path = '', tx_file: str | Path = '') str[source]
View a transaction.
- Parameters:
tx_body_file – A path to the transaction body file (JSON TxBody - optional).
tx_file – A path to the signed transaction file (JSON Tx - optional).
- Returns:
A transaction.
- Return type:
str
- view_tx_dict(tx_body_file: str | Path = '', tx_file: str | Path = '') dict[source]
Get a dict from transaction view.
- Parameters:
tx_body_file – A path to the transaction body file (JSON TxBody - optional).
tx_file – A path to the signed transaction file (JSON Tx - optional).
- Returns:
A transaction.
- Return type:
dict
- witness_tx(tx_body_file: str | Path, witness_name: str, signing_key_files: list[str | Path] | list[str] | list[Path] | tuple[()] = (), destination_dir: str | Path = '.') Path[source]
Create a transaction witness.
- Parameters:
tx_body_file – A path to file with transaction body.
witness_name – A name of the transaction witness.
signing_key_files – A list of paths to signing key files (optional).
destination_dir – A path to directory for storing artifacts (optional).
- Returns:
A path to transaction witness file.
- Return type:
Path
cardano_clusterlib.txtools module
Tools used by ClusterLib for constructing transactions.
- cardano_clusterlib.txtools.calculate_utxos_balance(utxos: list[UTXOData] | list[TxOut], coin: str = 'lovelace') int[source]
Calculate sum of UTxO balances.
- Parameters:
utxos – A list of UTxO data (either structs.UTXOData or structs.TxOut).
coin – A coin name (asset IDs).
- Returns:
A total balance.
- Return type:
int
- cardano_clusterlib.txtools.collect_data_for_build(clusterlib_obj: itp.ClusterLib, src_address: str, txins: list[UTXOData] | tuple[()] = (), txouts: list[TxOut] | tuple[()] = (), script_txins: list[ScriptTxIn] | tuple[()] = (), mint: list[Mint] | tuple[()] = (), tx_files: TxFiles | None = None, complex_certs: list[ComplexCert] | tuple[()] = (), complex_proposals: list[ComplexProposal] | tuple[()] = (), fee: int = 0, withdrawals: list[TxOut] | tuple[()] = (), script_withdrawals: list[ScriptWithdrawal] | tuple[()] = (), deposit: int | None = None, treasury_donation: int | None = None, src_addr_utxos: list[UTXOData] | None = None, skip_asset_balancing: bool = False) DataForBuild[source]
Collect data (txins, txouts, withdrawals) needed for building a transaction.
- Parameters:
clusterlib_obj – An instance of ClusterLib.
src_address – An address used for fee and inputs (if inputs not specified by txins).
txins – An iterable of structs.UTXOData, specifying input UTxOs (optional).
txouts – A list (iterable) of TxOuts, specifying transaction outputs (optional).
script_txins – An iterable of ScriptTxIn, specifying input script UTxOs (optional).
mint – An iterable of Mint, specifying script minting data (optional).
tx_files – A structs.TxFiles data container containing files needed for the transaction (optional).
complex_certs – An iterable of ComplexCert, specifying certificates script data (optional).
complex_proposals – An iterable of ComplexProposal, specifying proposals script data (optional).
fee – A fee amount (optional).
withdrawals – A list (iterable) of TxOuts, specifying reward withdrawals (optional).
script_withdrawals – An iterable of ScriptWithdrawal, specifying withdrawal script data (optional).
deposit – A deposit amount needed by the transaction (optional).
treasury_donation – A donation to the treasury to perform (optional).
src_addr_utxos – A list of UTxOs for the source address (optional).
skip_asset_balancing – A bool indicating if assets balancing should be skipped (build command balance the assets automatically in newer versions).
- Returns:
A data container with data for build(-raw) commands.
- Return type:
- cardano_clusterlib.txtools.filter_utxo_with_highest_amount(utxos: list[UTXOData], coin: str = 'lovelace') UTXOData[source]
Return data for UTxO with the highest amount.
- Parameters:
utxos – A list of UTxO data.
coin – A coin name (asset IDs).
- Returns:
A UTxO record with the highest amount.
- Return type:
- cardano_clusterlib.txtools.filter_utxos(utxos: list[UTXOData], utxo_hash: str = '', utxo_ix: int | None = None, amount: int | None = None, address: str = '', coin: str = '', datum_hash: str = '', inline_datum_hash: str = '') list[UTXOData][source]
Get UTxO records that match given filtering criteria.
- Parameters:
utxos – A list of UTxO data.
utxo_hash – A transaction identifier (optional).
utxo_ix – A UTxO index (optional).
amount – An amount of coin (optional).
address – A payment address (optional).
coin – A coin name (asset ID; optional).
datum_hash – A datum hash (optional).
inline_datum_hash – An inline datum hash (optional).
- Returns:
UTxO records that match given filtering criteria.
- Return type:
- cardano_clusterlib.txtools.get_joined_txouts(txouts: list[TxOut]) list[list[TxOut]][source]
Return list of joined TxOuts.
- cardano_clusterlib.txtools.get_proposal_file_argname(era_in_use: str = '') str[source]
Return the name of the proposal file argument.
- cardano_clusterlib.txtools.get_utxo(utxo_dict: dict, address: str = '', coins: list | tuple | set | frozenset = ()) list[UTXOData][source]
Return UTxO info for payment address.
- Parameters:
utxo_dict – A JSON output of query utxo.
address – A payment address.
coins – A list (iterable) of coin names (asset IDs).
- Returns:
A list of UTxO data.
- Return type:
list[structs.UTXOData]
cardano_clusterlib.types module
Module contents
Imports.
- class cardano_clusterlib.ClusterLib(state_dir: str | Path, slots_offset: int | None = None, socket_path: str | Path = '', command_era: str = 'latest')[source]
Bases:
objectMethods for working with cardano cluster using cardano-cli..
- slots_offset[source]
Difference in slots between cluster’s start era and Shelley era (Byron vs Shelley)
- socket_path[source]
A path to socket file for communication with the node. This overrides the CARDANO_NODE_SOCKET_PATH environment variable.
- cli(cli_args: list[str], timeout: float | None = None, add_default_args: bool = True) CLIOut[source]
Run the cardano-cli command.
- Parameters:
cli_args – A list of arguments for cardano-cli.
timeout – A timeout for the command, in seconds (optional).
add_default_args – Whether to add default arguments to the command (optional).
- Returns:
A data container containing command stdout and stderr.
- Return type:
- property g_address: AddressGroup[source]
Address group.
- property g_genesis: GenesisGroup[source]
Genesis group.
- property g_query: QueryGroup[source]
Query group.
- property g_stake_address: StakeAddressGroup[source]
Stake address group.
- property g_stake_pool: StakePoolGroup[source]
Stake pool group.
- property g_transaction: TransactionGroup[source]
Transaction group.
- set_socket_path(socket_path: str | Path | None) None[source]
Set a path to socket file for communication with the node.
- time_from_epoch_start(tip: dict | None = None) float[source]
How many seconds passed from start of the current epoch.
- time_to_epoch_end(tip: dict | None = None) float[source]
How many seconds to go to start of a new epoch.
- wait_for_block(block: int) int[source]
Wait for block number.
- Parameters:
block – A block number to wait for.
- Returns:
A block number of last added block.
- Return type:
int
- wait_for_epoch(epoch_no: int, padding_seconds: int = 0, future_is_ok: bool = True) int[source]
Wait for epoch no.
- Parameters:
epoch_no – A number of epoch to wait for.
padding_seconds – A number of additional seconds to wait for (optional).
future_is_ok – A bool indicating whether current epoch > epoch_no is acceptable (default: True).
- Returns:
The current epoch.
- Return type:
int
- wait_for_new_block(new_blocks: int = 1) int[source]
Wait for new block(s) to be created.
- Parameters:
new_blocks – A number of new blocks to wait for (optional).
- Returns:
A block number of last added block.
- Return type:
int