Make Wallet From Address
You can instantiate a wallet from a specified Bech32 Address to get a wallet object by calling the makeWalletFromAddress()
function.
Steps to Create a Wallet Object
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 { makeWalletFromAddress, Network } from "@evolution-sdk/lucid";
const provider = blockfrost;
const network: Network = "Mainnet"; // "Mainnet" | "Preview" | "Preprod" | "Custom"
const address = "addr1_... your address here"; // Bech32
const utxos = await provider.getUtxos(address); // UTxO[]
const wallet = makeWalletFromAddress(provider, network, address, utxos); // CIP-30
Last updated on