Wallet
Interfaces for managing the Mystiko wallet, including creating, checking, updating, and exporting operations.
Data Structure
Wallet
data structure is as follows:
Property | Type | Description |
---|---|---|
id | string | The wallet ID. |
createdAt | bigint | The creation time of the wallet. |
updatedAt | bigint | The last update time of the wallet. |
encryptedEntropy | string | The encrypted entropy of the wallet. |
hashedPassword | string | The hashed password of the wallet. |
accountNonce | number | The account nonce of the wallet. |
mnemonicType | MnemonicType | The account mnemonic type. |
List of supported MnemonicType
:
# Represents a mnemonic phrase used in web wallets, typically consisting of 12 words.
MnemonicType.WEB;
# Represents a mnemonic phrase used in Rust-based wallets, typically consisting of 24 words.
MnemonicType.RUST;
Create
Create a Mystiko Wallet.
import mystiko from '@mystikonetwork/node';
import { core } from '@mystikonetwork/protos';
const options = new core.handler.v1.CreateWalletOptions({
password: 'walletPassword',
mnemonic: {
mnemonicPhrase: "valley canyon ...",
mnemonicType: core.v1.MnemonicType.RUST,
},
});
const wallet = mystiko.wallet?.create(options);
The parameter list for CreateWalletOptions
:
Parameter | Required | Description |
---|---|---|
password | true | The password for the wallet. |
mnemonic | true | MnemonicOptions for the wallet. |
The parameter list for MnemonicOptions
:
Parameter | Required | Description |
---|---|---|
mnemonicPhrase | true | Mnemonic phrase for the wallet. |
mnemonicType | true | MnemonicType for the wallet. |
Check
CheckCurrent
Check current wallet.
import mystiko from '@mystikonetwork/node';
const wallet = mystiko.wallet?.checkCurrent();
CheckPassword
Check the password of the wallet.
import mystiko from '@mystikonetwork/node';
const wallet = mystiko.wallet?.checkPassword(walletPassword);
UpdatePassword
Update the password of the wallet.
import mystiko from '@mystikonetwork/node';
const wallet = mystiko.wallet?.updatePassword(oldPassword, newPassword);
ExportMnemonicPhrase
Export the mnemonic phrase of the wallet.
import mystiko from '@mystikonetwork/node';
const phrase = mystiko.wallet?.exportMnemonicPhrase(walletPassword);