For the complete documentation index optimized for AI agents, see llms.txt or llms-full.txt. A markdown version of this page is available by appending.mdto the URL or sendingAccept: text/markdown.
Connect to a Stack
For AI agents: the documentation index is at llms.txt (full corpus: llms-full.txt). A markdown source for this page is /using-stacks/connect.md.
This page shows how to add Arete to an existing project and connect to a deployed stack. It uses the public ORE mining stack as the example — no account or API key required.
Install & Connect
Section titled “Install & Connect”React: Install
Section titled “React: Install”npm install arete-react zustandReact: Add to your app
Section titled “React: Add to your app”import { AreteProvider, useArete } from "arete-react";import { ORE_STREAM_STACK } from "arete-stacks/ore";
function OreRounds() { const { views, isConnected } = useArete(ORE_STREAM_STACK); const { data: rounds, isLoading } = views.OreRound.latest.use({ take: 5, });
if (isLoading) return <div>Connecting...</div>;
return ( <div> <h1>Live ORE Mining Rounds {isConnected && "🟢"}</h1> {rounds?.map((round) => ( <div key={round.id?.round_id}> Round #{round.id?.round_id} — Motherlode: {round.state?.motherlode} </div> ))} </div> );}
export default function App() { return ( <AreteProvider websocketUrl="wss://ore.stack.arete.run"> <OreRounds /> </AreteProvider> );}React: Run it
Section titled “React: Run it”npm run devTypeScript: Install
Section titled “TypeScript: Install”npm install arete-typescriptTypeScript: Create a script
Section titled “TypeScript: Create a script”import { Arete } from "arete-typescript";import { ORE_STREAM_STACK, type OreRound } from "arete-stacks/ore";
async function main() { const a4 = await Arete.connect("wss://ore.stack.arete.run", { stack: ORE_STREAM_STACK, });
for await (const update of a4.views.OreRound.latest.watch()) { if (update.type === "upsert") { const round = update.data; console.log(`Round #${round.id?.round_id}`); console.log(` Motherlode: ${round.state?.motherlode}`); } }}
main().catch(console.error);TypeScript: Run it
Section titled “TypeScript: Run it”npx tsx stream.tsRust: Add to Cargo.toml
Section titled “Rust: Add to Cargo.toml”[dependencies]a4-sdk = "0.1.1"a4-stacks = "0.1.1"Rust: Write the code
Section titled “Rust: Write the code”use a4_sdk::prelude::*;use a4_stacks::ore::{OreStack, OreRound};
#[tokio::main]async fn main() -> anyhow::Result<()> { let a4 = Arete::<OreStack>::connect().await?;
let mut stream = a4.views.ore_round.latest().listen();
while let Some(round) = stream.next().await { println!("Round #{:?}", round.id.round_id); println!(" Motherlode: {:?}", round.state.motherlode); }
Ok(())}Rust: Run it
Section titled “Rust: Run it”cargo runFor quick inspection without any SDK, open your browser console and paste:
const ws = new WebSocket("wss://ore.stack.arete.run");
ws.onopen = () => { ws.send(JSON.stringify({ type: "subscribe", view: "OreRound/latest" }));};
ws.onmessage = (event) => { const data = JSON.parse(event.data); if (data.type === "upsert") console.log("Round update:", data.data);};How it Works
Section titled “How it Works”You connected to a deployed Arete stack. The ORE stack watches the Solana blockchain, extracts round data from on-chain transactions, and pushes typed updates to your app via WebSocket as they happen — no polling, no RPC calls, no indexer to run.
Solana
ORE program on-chain
Arete
ORE stack (deployed)
Your App
Typed live stream
The stack is public — just point your SDK at the WebSocket URL.
About Stack SDKs
Section titled “About Stack SDKs”A stack SDK tells the Arete client what entities and views are available, and provides the types for each. There are two ways to get one:
Pre-built for publicly deployed stacks (like ORE) — We publish ready-to-use SDKs for both TypeScript and Rust:
# TypeScript / Reactnpm install arete-stacksimport { ORE_STREAM_STACK } from "arete-stacks/ore";# Rust — add to Cargo.toml[dependencies]a4-stacks = "0.1.1"use a4_stacks::ore::{OreStack, OreRound};Generated from your own stack — When you build a custom stack, use the CLI to generate an SDK for any language:
a4 sdk create typescript my-stacka4 sdk create rust my-stackBoth approaches produce the same result: a typed SDK that works identically with the Arete client.
Available Public Stacks
Section titled “Available Public Stacks”| Stack | WebSocket URL | Data |
|---|---|---|
| ORE Mining Rounds | wss://ore.stack.arete.run | Live ORE mining round updates |
ORE Data Shape
Section titled “ORE Data Shape”Each OreRound update has this structure:
{ "id": { "round_id": 142857, "round_address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" }, "state": { "expires_at": 312645000, "motherlode": 5000000000, "total_deployed": 125000000000, "total_vaulted": 12500000000, "total_winnings": 98500000000 }, "results": { "top_miner": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM", "top_miner_reward": 2500000000, "winning_square": 18, "did_hit_motherlode": false }, "metrics": { "deploy_count": 1847, "total_deployed_sol": 125000000000, "checkpoint_count": 423 }}| Section | Description |
|---|---|
id | Primary key (round_id) and lookup index (round_address) |
state | Current round state from on-chain account |
results | Round outcome including computed fields |
metrics | Aggregated counts and sums from instructions |
Next Steps
Section titled “Next Steps”- How It Works — Understand Stacks, Views, and how the stream model works
- React SDK — React hooks and patterns in depth
- TypeScript SDK — Use with Node.js, Vue, Svelte, or vanilla JS
- Rust SDK — Native Rust client
- Build Your Own Stack — Stream data from your own on-chain program