Documentation
Core Concepts
Wallet Creation
From Private Key

Make Wallet From Private Key

You can instantiate a wallet from a Bech32 (opens in a new tab) Private Key to get a CIP-30 (opens in a new tab) wallet object by calling the makeWalletFromPrivateKey function. Please note that, only an Enterprise Address (without stake credential) can be derived.

Specify Provider

It can be Blockfrost (opens in a new tab), Koios (opens in a new tab), Maestro (opens in a new tab), etc. Even your custom provider, as long as it implements the Provider interface.

For example, with Blockfrost provider:

import { Blockfrost, Provider } from "@lucid-evolution/lucid";
 
/**
 * The endpoint based on the Cardano network,
 * please refer to Blockfrost documentations.
 */
const blockfrostURL: string = process.env.BF_URL!;
 
/**
 * Your secret Blockfrost Project ID
 */
const blockfrostPID: string = process.env.BF_PID!;
 
const blockfrost: Provider = new Blockfrost(
  blockfrostURL,
  blockfrostPID,
);

Other providers follow a similar pattern.

Create CIP-30 Wallet

import { makeWalletFromPrivateKey } from "@lucid-evolution/lucid";
 
const provider = blockfrost;
const network: Network = "Mainnet"; // "Mainnet" | "Preview" | "Preprod" | "Custom"
const privateKey = "bech32 private key here ...";
const wallet = makeWalletFromPrivateKey(provider, network, privateKey); // CIP-30