Skip to content

algokit_utils.account

Functions

create_kmd_wallet_accountCreates a wallet with specified name
get_accountReturns an Algorand account with private key loaded by convention based on the given name identifier.
get_account_from_mnemonicConvert a mnemonic (25 word passphrase) into an Account
get_dispenser_accountReturns an Account based on DISPENSER_MNENOMIC environment variable or the default account on LocalNet
get_kmd_wallet_accountReturns wallet matching specified name and predicate or None if not found
get_localnet_default_accountReturns the default Account in a LocalNet instance
get_or_create_kmd_wallet_accountReturns a wallet with specified name, or creates one if not found

API

algokit_utils.account.create_kmd_wallet_account

create_kmd_wallet_account(kmd_client: algosdk.kmd.KMDClient, name: str) → algokit_utils.models.Account

Creates a wallet with specified name

algokit_utils.account.get_account

get_account(client: algosdk.v2client.algod.AlgodClient, name: str, fund_with_algos: float = 1000, kmd_client: KMDClient | None = None) → algokit_utils.models.Account

Returns an Algorand account with private key loaded by convention based on the given name identifier.

Convention

Non-LocalNet: will load os.environ[f"{name}_MNEMONIC"] as a mnemonic secret Be careful how the mnemonic is handled, never commit it into source control and ideally load it via a secret storage service rather than the file system.

LocalNet: will load the account from a KMD wallet called {name} and if that wallet doesn’t exist it will create it and fund the account for you

This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).

Example

If you have a mnemonic secret loaded into os.environ["ACCOUNT_MNEMONIC"] then you can call the following to get that private key loaded into an account object:

account = get_account('ACCOUNT', algod)

If that code runs against LocalNet then a wallet called ‘ACCOUNT’ will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.

algokit_utils.account.get_account_from_mnemonic

get_account_from_mnemonic(mnemonic: str) → algokit_utils.models.Account

Convert a mnemonic (25 word passphrase) into an Account

algokit_utils.account.get_dispenser_account

get_dispenser_account(client: algosdk.v2client.algod.AlgodClient) → algokit_utils.models.Account

Returns an Account based on DISPENSER_MNENOMIC environment variable or the default account on LocalNet

algokit_utils.account.get_kmd_wallet_account

get_kmd_wallet_account(client: algosdk.v2client.algod.AlgodClient, kmd_client: algosdk.kmd.KMDClient, name: str, predicate: Callable[[dict[str, Any]], bool] | None = None) → algokit_utils.models.Account | None

Returns wallet matching specified name and predicate or None if not found

algokit_utils.account.get_localnet_default_account

get_localnet_default_account(client: algosdk.v2client.algod.AlgodClient) → algokit_utils.models.Account

Returns the default Account in a LocalNet instance

algokit_utils.account.get_or_create_kmd_wallet_account

get_or_create_kmd_wallet_account(client: algosdk.v2client.algod.AlgodClient, name: str, fund_with_algos: float = 1000, kmd_client: KMDClient | None = None) → algokit_utils.models.Account

Returns a wallet with specified name, or creates one if not found