Wallet Configuration
The SDK supports universal wallet configuration through a unified Wallet type that must support both message and transaction signing (MessageSigner & TransactionSigner). This enables compatibility with both browser wallets (wallet-standard) and keypair-based wallets.
Wallet Requirements
The wallet must implement both MessageSigner and TransactionSigner interfaces from @solana/kit. This allows the SDK to use the wallet for:
- Message signing - For API authentication and authorization
- Transaction signing - For on-chain operations
Keypair Helpers
The SDK provides convenient helper functions to create wallets without needing to install @solana/kit directly.
Generate a New Wallet
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, function generateWallet(): Promise<Wallet>Generate a new random wallet (keypair signer).generateWallet } from '@nosana/kit';
const const wallet: Walletwallet = await function generateWallet(): Promise<Wallet>Generate a new random wallet (keypair signer).generateWallet();
var console: ConsoleThe `console` module provides a simple debugging console that is similar to the
JavaScript console mechanism provided by web browsers.
The module exports two specific components:
* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstdout) and
[`process.stderr`](https://nodejs.org/docs/latest-v24.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
_**Warning**_: The global console object's methods are neither consistently
synchronous like the browser APIs they resemble, nor are they consistently
asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v24.x/api/process.html#a-note-on-process-io) for
more information.
Example using the global `console`:
```js
console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
// Error: Whoops, something bad happened
// at [eval]:5:15
// at Script.runInThisContext (node:vm:132:18)
// at Object.runInThisContext (node:vm:309:38)
// at node:internal/process/execution:77:19
// at [eval]-wrapper:6:22
// at evalScript (node:internal/process/execution:76:60)
// at node:internal/main/eval_string:23:3
const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr
```
Example using the `Console` class:
```js
const out = getStreamSomehow();
const err = getStreamSomehow();
const myConsole = new console.Console(out, err);
myConsole.log('hello world');
// Prints: hello world, to out
myConsole.log('hello %s', 'world');
// Prints: hello world, to out
myConsole.error(new Error('Whoops, something bad happened'));
// Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson';
myConsole.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to err
```console.Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)Prints to `stdout` with newline. Multiple arguments can be passed, with the
first used as the primary message and all additional used as substitution
values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)).
```js
const count = 5;
console.log('count: %d', count);
// Prints: count: 5, to stdout
console.log('count:', count);
// Prints: count: 5, to stdout
```
See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.log(const wallet: Walletwallet.address: NominalType<"brand", "Address"> & NominalType<"stringEncoding", "base58"> & stringaddress);
const const client: NosanaClientclient = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient();
const client: NosanaClientclient.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const wallet: Walletwallet;Load from a Keypair File
Load a wallet from a Solana CLI keypair JSON file (as created by solana-keygen). Defaults to ~/.config/solana/id.json.
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, function loadWalletFromFile(filePath?: string): 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.loadWalletFromFile } from '@nosana/kit';
// Load the default Solana CLI keypair
const const wallet: Walletwallet = await function loadWalletFromFile(filePath?: string): 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.loadWalletFromFile();
// Or specify a custom path
const const wallet2: Walletwallet2 = await function loadWalletFromFile(filePath?: string): 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.loadWalletFromFile('/path/to/keypair.json');
const const client: NosanaClientclient = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient();
const client: NosanaClientclient.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const wallet: Walletwallet;Create from a Base58 Private Key
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, function createWalletFromBase58(base58Key: string): Promise<Wallet>Create a wallet from a base58-encoded private key string.
This accepts the full 64-byte keypair encoded as base58, as commonly
exported from wallets and tools like `solana-keygen`.createWalletFromBase58 } from '@nosana/kit';
const const wallet: Walletwallet = await function createWalletFromBase58(base58Key: string): Promise<Wallet>Create a wallet from a base58-encoded private key string.
This accepts the full 64-byte keypair encoded as base58, as commonly
exported from wallets and tools like `solana-keygen`.createWalletFromBase58(
'your-base-58-encoded-private-key'
);
const const client: NosanaClientclient = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient();
const client: NosanaClientclient.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const wallet: Walletwallet;Create from Bytes
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, function createWalletFromBytes(bytes: Uint8Array | ReadonlyArray<number>): Promise<Wallet>Create a wallet from a 64-byte secret key (Uint8Array or number array).
The bytes should be a 64-byte array containing the 32-byte private key
followed by the 32-byte public key, as used by Solana CLI keypair files.createWalletFromBytes } from '@nosana/kit';
const const secretKey: Uint8Array<ArrayBuffer>secretKey = new var Uint8Array: Uint8ArrayConstructor
new (elements: Iterable<number>) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array([174, 47, 154, 16, 202, 193, 206, 113, /* ... */]);
const const wallet: Walletwallet = await function createWalletFromBytes(bytes: Uint8Array | ReadonlyArray<number>): Promise<Wallet>Create a wallet from a 64-byte secret key (Uint8Array or number array).
The bytes should be a 64-byte array containing the 32-byte private key
followed by the 32-byte public key, as used by Solana CLI keypair files.createWalletFromBytes(const secretKey: Uint8Array<ArrayBuffer>secretKey);
const const client: NosanaClientclient = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient();
const client: NosanaClientclient.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const wallet: Walletwallet;Using @solana/kit Directly
The SDK also re-exports the underlying @solana/kit keypair functions if you need more control:
import {
function generateKeyPairSigner(extractable?: boolean): Promise<KeyPairSigner>Generates a signer capable of signing messages and transactions by generating
a
{@link
CryptoKeyPair
}
and creating a
{@link
KeyPairSigner
}
from it.generateKeyPairSigner,
function createKeyPairSignerFromBytes(bytes: ReadonlyUint8Array, extractable?: boolean): Promise<KeyPairSigner>Creates a new
{@link
KeyPairSigner
}
from a 64-bytes `Uint8Array` secret key (private key and public key).createKeyPairSignerFromBytes,
function createKeyPairFromBytes(bytes: ReadonlyUint8Array, extractable?: boolean): Promise<CryptoKeyPair>Given a 64-byte `Uint8Array` secret key, creates an Ed25519 public/private key pair for use with
other methods in this package that accept [`CryptoKey`](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey)
objects.createKeyPairFromBytes,
function createSignerFromKeyPair(keyPair: CryptoKeyPair): Promise<KeyPairSigner>Creates a
{@link
KeyPairSigner
}
from a provided
{@link
CryptoKeyPair
}
.
The
{@link
MessagePartialSigner#signMessages signMessages
}
and
{@link
TransactionPartialSigner#signTransactions signTransactions
}
functions of the returned signer will use the private key of the provided
key pair to sign messages and transactions.
Note that both the
{@link
MessagePartialSigner#signMessages signMessages
}
and
{@link
TransactionPartialSigner#signTransactions signTransactions
}
implementations
are parallelized, meaning that they will sign all provided messages and transactions in parallel.createSignerFromKeyPair,
} from '@nosana/kit';
const const signer: KeyPairSigner<string>signer = await function generateKeyPairSigner(extractable?: boolean): Promise<KeyPairSigner>Generates a signer capable of signing messages and transactions by generating
a
{@link
CryptoKeyPair
}
and creating a
{@link
KeyPairSigner
}
from it.generateKeyPairSigner();Browser Wallets (Wallet-Standard)
Full support for wallet-standard compatible browser wallets (Phantom, Solflare, etc.).
import { createNosanaClient } from '@nosana/kit';
import { useWalletAccountSigner } from '@nosana/solana-vue';
// Create client
const client = createNosanaClient();
// Set browser wallet (wallet-standard compatible)
client.wallet = useWalletAccountSigner(account, currentChain);Configuration Options
Wallets can be set at client initialization or dynamically assigned.
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, type NosanaNetwork = "mainnet" | "devnet" | "localnet"
const NosanaNetwork: {
readonly MAINNET: "mainnet";
readonly DEVNET: "devnet";
readonly LOCALNET: "localnet";
}
NosanaNetwork, function generateWallet(): Promise<Wallet>Generate a new random wallet (keypair signer).generateWallet } from '@nosana/kit';
const const myWallet: WalletmyWallet = await function generateWallet(): Promise<Wallet>Generate a new random wallet (keypair signer).generateWallet();
const const anotherWallet: WalletanotherWallet = await function generateWallet(): Promise<Wallet>Generate a new random wallet (keypair signer).generateWallet();
// Option 1: Set wallet during initialization
const const client1: NosanaClientclient1 = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient(const NosanaNetwork: {
readonly MAINNET: "mainnet";
readonly DEVNET: "devnet";
readonly LOCALNET: "localnet";
}
NosanaNetwork.type MAINNET: "mainnet"MAINNET, {
PartialClientConfig.wallet?: Wallet | undefinedwallet: const myWallet: WalletmyWallet,
});
// Option 2: Set wallet dynamically
const const client2: NosanaClientclient2 = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient();
const client2: NosanaClientclient2.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const myWallet: WalletmyWallet;
// Option 3: Change wallet at runtime
const client2: NosanaClientclient2.NosanaClient.wallet: Wallet | undefinedThe wallet. Must be a Wallet (supports both message and transaction signing).
Set this property directly to configure the wallet.wallet = const anotherWallet: WalletanotherWallet;Type Safety
The SDK leverages @solana/kit types for compile-time safety, ensuring wallet compatibility before runtime.