Make Wallet From Private Key
You can instantiate a wallet from a Bech32 Private Key to get a wallet object by calling the makeWalletFromPrivateKey()
function. Please note that, only an Enterprise Address (without stake credential) can be derived.
Steps to Create a CIP-30 Wallet
Specify the Provider
It can be Blockfrost , Koios , Maestro , etc. Even a custom provider, as long as it implements the Provider
interface.
For example, here’s how to instantiate a Blockfrost provider:
import { Blockfrost, Provider } from "@evolution-sdk/lucid";
const blockfrostURL: string = process.env.BF_URL!;
const blockfrostPID: string = process.env.BF_PID!;
const blockfrost: Provider = new Blockfrost(
blockfrostURL, // The endpoint based on the Cardano network, please refer to Blockfrost documentation
blockfrostPID, // Your secret Blockfrost Project ID
);
💡
Other providers follow a similar pattern.
Create the Wallet Object
import { makeWalletFromPrivateKey, Network } from "@evolution-sdk/lucid";
const provider = blockfrost;@evolution-sdk
const network: Network = "Mainnet"; // "Mainnet" | "Preview" | "Preprod" | "Custom"
const privateKey = "bech32 private key here ...";
const wallet = makeWalletFromPrivateKey(provider, network, privateKey); // CIP-30
Last updated on