Basic Usage Examples
This page demonstrates common patterns for using Nosana Kit.
Initialize Client
ts
import { createNosanaClient } from '@nosana/kit';
const client = createNosanaClient();ts
import { createNosanaClient, NosanaNetwork } from '@nosana/kit';
const client = createNosanaClient(NosanaNetwork.DEVNET);TIP
The createNosanaClient function returns a fully typed NosanaClient instance. All methods and properties are type-checked at compile time.
Fetch a Job
ts
import { createNosanaClient } from '@nosana/kit';
const client = createNosanaClient();INFO
The Job type includes all properties from the on-chain account data. Hover over job in your IDE to see the full type definition, or check the SDK Reference.
Query Jobs with Filters
ts
import { createNosanaClient, JobState } from '@nosana/kit';
const client = createNosanaClient();Set Up Wallet
Wallet Configuration
A wallet is required for signing transactions. You can set it during client initialization or dynamically.
ts
import { createNosanaClient, NosanaNetwork } from '@nosana/kit';
import { generateKeyPairSigner } from '@solana/kit';
import type { Wallet } from '@nosana/kit';
// Option 1: Set wallet during initialization
const keypair: Wallet = await generateKeyPairSigner();
const client = createNosanaClient(NosanaNetwork.MAINNET, {
wallet: keypair,
});ts
import { Wallet, createNosanaClient, address } from '@nosana/kit';
import { generateKeyPairSigner } from '@solana/kit';
const client = createNosanaClient();
// Option 2: Set wallet dynamically
const keypair: Wallet = await generateKeyPairSigner();
client.wallet = keypair;
// Now you can perform transactions
const instruction = await client.jobs.post({
market: address('market-address'),
timeout: 3600,
ipfsHash: 'QmXxx...',
});
await client.solana.buildSignAndSend(instruction);WARNING
Never share your private key or seed phrase. Always use secure key management practices in production.