Cardanoex.Wallet (cardanoex v0.6.0)
The wallet module lets you work with Cardano wallets.
Wallets are identified by unique ID which is deterministically derived from the seed (mnemonic phrase), so each time you delete and create a wallet again, it receives the same ID.
Link to this section Summary
Functions
Create and restore a wallet from a mnemonic sentence.
Delete wallet by wallet id
Fetch a wallet by wallet id
Return the UTxOs distribution across the whole wallet, in the form of a histogram.
Return a list of known wallets, ordered from oldest to newest.
Update the name of a wallet
Update passphrase for a wallet
Link to this section Types
assets()
Specs
balance()
Specs
balance() :: %{ available: %{quantity: non_neg_integer(), unit: String.t()}, reward: %{quantity: non_neg_integer(), unit: String.t()}, total: %{quantity: non_neg_integer(), unit: String.t()} }
delegation()
Specs
passphrase()
Specs
passphrase() :: %{last_updated_at: String.t()}
state()
Specs
state() :: %{ progress: %{quantity: non_neg_integer(), unit: String.t()}, status: String.t() }
tip()
Specs
tip() :: %{ absolute_slot_number: non_neg_integer(), epoch_number: non_neg_integer(), height: %{quantity: non_neg_integer(), unit: String.t()}, slot_number: non_neg_integer(), time: String.t() }
utxo_stats()
Specs
utxo_stats() :: %{ distribution: %{ "10": non_neg_integer(), "100": non_neg_integer(), "1000": non_neg_integer(), "10000": non_neg_integer(), "100000": non_neg_integer(), "1000000": non_neg_integer(), "10000000": non_neg_integer(), "100000000": non_neg_integer(), "1000000000": non_neg_integer(), "10000000000": non_neg_integer(), "100000000000": non_neg_integer(), "1000000000000": non_neg_integer(), "10000000000000": non_neg_integer(), "100000000000000": non_neg_integer(), "1000000000000000": non_neg_integer(), "10000000000000000": non_neg_integer(), "45000000000000000": non_neg_integer() }, scale: String.t(), total: %{quantity: non_neg_integer(), unit: String.t()} }
wallet()
Specs
wallet() :: %{ address_pool_gap: non_neg_integer(), assets: assets(), balance: balance(), delegation: delegation(), id: String.t(), name: String.t(), passphrase: passphrase(), state: state(), tip: tip() }
Link to this section Functions
create_wallet(options \\ [])
Specs
create_wallet( name: String.t(), mnemonic_sentence: String.t(), passphrase: String.t(), mnemonic_second_factor: String.t() ) :: {:error, String.t()} | {:ok, wallet()}
Create and restore a wallet from a mnemonic sentence.
Options
name
- A human readable name for the walletmnemonic_sentence
- A list of bip-0039 mnemonic words. 15-24 words.passphrase
- A master passphrase to lock and protect the wallet for sensitive operation (e.g. sending funds)mnemonic_second_factor
- An optional passphrase used to encrypt the mnemonic sentence. A list of bip-0039 mnemonic words. 9-12 words.address_pool_gap
- Number of consecutive unused addresses allowed. Default is 20.IMPORTANT DISCLAIMER: Using values other than 20 automatically makes your wallet invalid with regards to BIP-44 address discovery. It means that you will not be able to fully restore your wallet in a different software which is strictly following BIP-44. Beside, using large gaps is not recommended as it may induce important performance degradations. Use at your own risks.
delete(wallet_id)
Specs
Delete wallet by wallet id
Options
wallet_id
- hex based string. 40 characters
fetch(wallet_id)
Specs
Fetch a wallet by wallet id
Options
wallet_id
- hex based string. 40 characters
fetch_utxo_stats(wallet_id)
Specs
fetch_utxo_stats(String.t()) :: {:error, String.t()} | {:ok, utxo_stats()}
Return the UTxOs distribution across the whole wallet, in the form of a histogram.
Options
wallet_id
- hex based string. 40 characters
list()
Specs
Return a list of known wallets, ordered from oldest to newest.
update(wallet_id, new_name)
Specs
Update the name of a wallet
Options
wallet_id
- hex based string. 40 charactersnew_name
- the new name for the wallet
update_passphrase(wallet_id, old_passphrase, new_passphrase)
Specs
Update passphrase for a wallet
Options
wallet_id
- hex based string. 40 charactersold_passphrase
- the old passphrasenew_passphrase
- the new passphrase