Create a wallet

You are provided with multiple options to create and import a wallet

Private Key

Generate a new private key

const privateKey = generatePrivateKey(); // Bech32 encoded private key
console.log(privateKey);

Seed Phrase

Generate a new seed phrase (mnemonic)

const seedPhrase = generateSeedPhrase(); // BIP-39
console.log(seedPhrase);

Choosing Wallet

Use any suitable method to select a wallet and interact with the blockchain through it

Private Key

Select a wallet using a private key

lucid.selectWallet.fromPrivateKey(privateKey);

Seed Phrase

Select a wallet using a seed phrase (mnemonic)

const seedPhrase = "your seed phrase here...";
lucid.selectWallet.fromSeed(seedPhrase);

Wallet API

If you're integrating with a wallet provider that exposes an API conforming to the WalletApi interface. This works for any CIP-30 (opens in a new tab) compliant wallet.

// `externalWalletApi` is your wallet provider's API
const walletApi: WalletApi = externalWalletApi;
lucid.selectWallet.fromAPI(walletApi);

Address-only

This method will create a limited wallet that can still query the address and its UTxOs. You can use it to build transactions that others will sign, as it cannot sign transactions (no private key).

const address = "addr_test...";
const utxos = await lucid.utxosAt(address);
lucid.selectWallet.fromAddress(address, utxos);
⚠️

Transactions built with an address-only wallet will need to be signed by a wallet with the actual private keys before they can be submitted.

Query your wallet

Wallet queries are like asking "what's in my wallet?". You are able to fetch data associated with the selected wallet.

Address

const address = await lucid.wallet().address(); // Bech32 encodedaddress

UTXOs

UTXOs associated with the selected wallet

const utxos = await lucid.wallet().getUtxos();

Delegation

Query your wallet's stake delegation status:

const delegation = await lucid.wallet().getDelegation();