Function: loadWalletFromFile()
ts
function loadWalletFromFile(filePath?): Promise<Wallet>;Load a wallet from a Solana CLI keypair JSON file.
Reads a JSON file containing a byte array (as used by solana-keygen) and creates a wallet from it. Defaults to ~/.config/solana/id.json if no path is provided.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath? | string | Path to the keypair JSON file (default: ~/.config/solana/id.json) |
Returns
A wallet loaded from the file
Example
ts
import { loadWalletFromFile } from '@nosana/kit';
// Load default Solana CLI keypair
const wallet = await loadWalletFromFile();
// Or specify a custom path
const wallet = await loadWalletFromFile('/path/to/keypair.json');
console.log(wallet.address);