mnemonicAccountFromEnvironment
mnemonicAccountFromEnvironment(
account
,algod
,kmdClient
?):Promise
<Account
|SigningAccount
>
Defined in: src/account/account.ts:97
Parameters
account
The details of the account to get, either the name identifier (string) or an object with:
name
: string: The name identifier of the accountfundWith
: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 ALGO will be funded from the dispenser account
string
| { fundWith
: AlgoAmount
; name
: string
; }
algod
AlgodClient
An algod client
kmdClient?
KmdClient
An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
Returns
Promise
<Account
| SigningAccount
>
The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
Example
If you have a mnemonic secret loaded into process.env.MY_ACCOUNT_MNEMONIC
then you can call the following to get that private key loaded into an account object:
const account = await mnemonicAccountFromEnvironment('MY_ACCOUNT', algod)
If that code runs against LocalNet then a wallet called MY_ACCOUNT
will automatically be created with an account that is automatically funded with 1000 (default) ALGO from the default LocalNet dispenser.
If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.