Wallet
You can instantiate a wallet object from seed without binding it with a Lucid object by calling the walletFromSeed
function. For example, to use it with an emulator or to run test scenarios.
Generate Seed Phrase
import { generateSeedPhrase } from "@lucid-evolution/lucid";
const seedPhrase = generateSeedPhrase(); // BIP-39
console.log(seedPhrase);
Create Wallet
import { walletFromSeed } from "@lucid-evolution/lucid";
const seedPhrase = "your seed phrase here ...";
const wallet = walletFromSeed(seedPhrase);
console.log(wallet); // { address, rewardAddress, paymentKey, stakeKey }
Discover Own Used Tx Key Hashes
There is also a utility function associated with the wallet module to discover which key hashes are used from a transaction object limited to the specified UTXOs.
import { discoverOwnUsedTxKeyHashes } from "@lucid-evolution/lucid";
const tx: TxSignBuilder = await lucid
.newTx()
// ... build your transaction
.complete();
const ownKeyHashes: Array<KeyHash> = ["KeyHash1", "KeyHash2", "OtherKeyHash"];
const ownUtxos: Array<UTxO> = utxos;
const usedKeyHashes: Array<KeyHash> = discoverOwnUsedTxKeyHashes(
tx.toTransaction(),
ownKeyHashes,
ownUtxos,
);
console.log(usedKeyHashes); // ["KeyHash1", "KeyHash2"]