Skip to content

KmdAccountManager

Defined in: src/kmd-account-manager.ts:13

Provides abstractions over a KMD instance that makes it easier to get and manage accounts using KMD.

new KmdAccountManager(clientManager): KmdAccountManager

Defined in: src/kmd-account-manager.ts:21

Create a new KMD manager.

ClientManager

A ClientManager client to use for algod and kmd clients

KmdAccountManager

getLocalNetDispenserAccount(): Promise<AddressWithTransactionSigner>

Defined in: src/kmd-account-manager.ts:191

Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts).

Promise<AddressWithTransactionSigner>

The default LocalNet dispenser account

const dispenser = await kmdAccountManager.getLocalNetDispenserAccount()

getOrCreateWalletAccount(name, fundWith?): Promise<AddressWithTransactionSigner>

Defined in: src/kmd-account-manager.ts:147

Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.

This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).

This significantly speeds up local dev time and improves experience since you can write code that just works first go without manual config in a fresh LocalNet.

If this is used via mnemonicAccountFromEnvironment, then you can even use the same code that runs on production without changes for local development!

string

The name of the wallet to retrieve / create

AlgoAmount

The number of Algo to fund the account with when it gets created, if not specified then 1000 ALGO will be funded from the dispenser account

Promise<AddressWithTransactionSigner>

An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you

// Idempotently get (if exists) or create (if it doesn't exist yet) an account by name using KMD
// if creating it then fund it with 2 ALGO from the default dispenser account
const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algo())
// This will return the same account as above since the name matches
const existingAccount = await kmdAccountManager.getOrCreateWalletAccount('account1')

getWalletAccount(walletName, predicate?, sender?): Promise<AddressWithTransactionSigner | undefined>

Defined in: src/kmd-account-manager.ts:65

Returns an Algorand signing account with private key loaded from the given KMD wallet (identified by name).

string

The name of the wallet to retrieve an account from

(account) => boolean

An optional filter to use to find the account (otherwise it will return a random account from the wallet)

The optional sender address to use this signer for (aka a rekeyed account)

string | Address

Promise<AddressWithTransactionSigner | undefined>

The signing account (with private key loaded) or undefined if no matching wallet or account was found

const defaultDispenserAccount = await kmdAccountManager.getWalletAccount(
'unencrypted-default-wallet',
a => a.status !== 'Offline' && a.amount > 1_000_000_000
)

kmd(): Promise<KmdClient>

Defined in: src/kmd-account-manager.ts:30

Promise<KmdClient>