Function: generateWalletToFile()
ts
function generateWalletToFile(filePath): Promise<Wallet>;Generate a new random wallet and write it to a Solana CLI keypair JSON file, the inverse of loadWalletFromFile. The file is written with mode 0600 and any missing directories are created; an existing file is never overwritten.
Parameters
| Parameter | Type | Description |
|---|---|---|
filePath | string | Path to write the keypair JSON file to |
Returns
The new wallet
Throws
If a file already exists at filePath.
Example
ts
import { generateWalletToFile } from '@nosana/kit';
const wallet = await generateWalletToFile('/path/to/keypair.json');
console.log(wallet.address);