Skip to main content

iota_sdk.utils

Utils Objects

class Utils()

Utility functions.

bech32_to_hex

@staticmethod
def bech32_to_hex(bech32: str) -> HexStr

Convert a Bech32 string to a hex string.

hex_to_bech32

@staticmethod
def hex_to_bech32(hex: HexStr, bech32_hrp: str) -> str

Convert a hex encoded address to a Bech32 encoded address.

alias_id_to_bech32

@staticmethod
def alias_id_to_bech32(alias_id: HexStr, bech32_hrp: str) -> str

Convert an alias id to a Bech32 encoded address.

nft_id_to_bech32

@staticmethod
def nft_id_to_bech32(nft_id: HexStr, bech32_hrp: str) -> str

Convert an NFT ID to a Bech32 encoded address.

hex_public_key_to_bech32_address

@staticmethod
def hex_public_key_to_bech32_address(hex: HexStr, bech32_hrp: str) -> str

Convert a hex encoded public key to a Bech32 encoded address.

parse_bech32_address

@staticmethod
def parse_bech32_address(address: str) -> Address

Parse a string into a valid address.

is_address_valid

@staticmethod
def is_address_valid(address: str) -> bool

Check whether a string is a valid Bech32 encoded address.

generate_mnemonic

@staticmethod
def generate_mnemonic() -> str

Generate a new mnemonic.

mnemonic_to_hex_seed

@staticmethod
def mnemonic_to_hex_seed(mnemonic: str) -> HexStr

Convert a mnemonic to a hex encoded seed.

compute_alias_id

@staticmethod
def compute_alias_id(output_id: OutputId) -> HexStr

Compute the alias id for the given alias output id.

compute_foundry_id

@staticmethod
def compute_foundry_id(alias_id: HexStr, serial_number: int,
token_scheme_type: int) -> HexStr

Compute the foundry id.

compute_inputs_commitment

@staticmethod
def compute_inputs_commitment(inputs: List[Output]) -> HexStr

Compute the input commitment from the output objects that are used as inputs to fund the transaction.

compute_storage_deposit

@staticmethod
def compute_storage_deposit(output, rent) -> HexStr

Compute the required storage deposit of an output.

compute_nft_id

@staticmethod
def compute_nft_id(output_id: OutputId) -> HexStr

Compute the NFT id for the given NFT output id.

compute_output_id

@staticmethod
def compute_output_id(transaction_id: HexStr, index: int) -> OutputId

Compute the output id from transaction id and output index.

compute_token_id

@staticmethod
def compute_token_id(alias_id: HexStr, serial_number: int,
token_scheme_type: int) -> HexStr

Compute a token id from the alias id, serial number and token scheme type.

block_id

@staticmethod
def block_id(block: Block) -> HexStr

Return a block ID (Blake2b256 hash of block bytes) from a block.

hash_transaction_essence

@staticmethod
def hash_transaction_essence(essence) -> HexStr

Compute the hash of a transaction essence.

verify_ed25519_signature

@staticmethod
def verify_ed25519_signature(signature: Ed25519Signature,
message: HexStr) -> bool

Verify an Ed25519 signature against a message.

verify_secp256k1_ecdsa_signature

@staticmethod
def verify_secp256k1_ecdsa_signature(public_key: HexStr, signature: HexStr,
message: HexStr) -> bool

Verify a Secp256k1Ecdsa signature against a message.

UtilsError Objects

class UtilsError(Exception)

A utils error.