Solarium

Quickstart

Submit your first verifiable AI inference task on Solana in under 5 minutes.

1. Install the SDK

Add the Solarium SDK to your project.

bash
npm install @solarium-labs/sdk @project-serum/anchor @solana/web3.js

2. Initialize the Client

Create a SolariumClient instance using an Anchor provider.

typescript
import { SolariumClient } from '@solarium-labs/sdk';
import { AnchorProvider, Wallet } from '@project-serum/anchor';
import { Connection } from '@solana/web3.js';

const connection = new Connection("https://api.devnet.solana.com");
const provider = new AnchorProvider(connection, wallet, {});

// Initialize the Solarium Client
const client = new SolariumClient(provider);

3. Create a Task

Submit an inference task to the network. The task is assigned to a Worker node.

typescript
// Submit a task with a prompt and escrow budget
const taskId = await client.createTask({
  tier: "LLAMA_3_70B",
  prompt: "Verify the authenticity of this payload: { data: 'X' }",
  budget: 0.05, // SOL
});

console.log("Task submitted successfully:", taskId);

4. Wait for Verdict

Poll the on-chain state until the Commit-Reveal cycle completes and a verdict is finalized.

typescript
// Await the network's consensus via Optimistic Finality
const result = await client.pollTaskFinality(taskId);

console.log("Network Verdict:", result.verdict);
console.log("Confidence Score:", result.confidence);

if (result.confidence > 90) {
  // Execute your smart contract logic
}