Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/hypertekorg/hyperstack/llms.txt

Use this file to discover all available pages before exploring further.

Views provide type-safe access to your indexed data. Hyperstack supports two view modes:
  • State views - Single entity by key
  • List views - Collection of entities

View Modes

State View

Returns a single entity by key. Used for accessing specific records.
// Get a single token by mint address
const token = await client.views.tokens.state.get('So11111...');
// token: Token | null

// Synchronous access to cached data
const cached = client.views.tokens.state.getSync('So11111...');
// cached: Token | null | undefined

List View

Returns an array of entities. Used for collections and queries.
// Get all tokens
const tokens = await client.views.tokens.list.get();
// tokens: Token[]

// Synchronous access
const cached = client.views.tokens.list.getSync();
// cached: Token[] | undefined

View Path Format

View paths follow the pattern: {EntityName}/{mode}
ModeReturnsExample
stateSingle entityToken/state
listArray of entitiesToken/list
The entity name must match the #[entity(name = "EntityName")] in your Rust stream definition.

Querying Views

List Parameters

// Limit results
for await (const tokens of client.views.tokens.list.use({ limit: 10 })) {
  console.log('Top 10 tokens:', tokens);
}

// Filter by field
for await (const tokens of client.views.tokens.list.use({
  where: { volume: { gte: 10000 } }
})) {
  console.log('High volume tokens:', tokens);
}

// Multiple conditions
for await (const tokens of client.views.tokens.list.use({
  where: {
    volume: { gte: 10000 },
    created_at: { gt: Date.now() - 86400000 }
  },
  limit: 20
})) {
  console.log('Recent high volume:', tokens);
}
Available operators:
  • eq - Equals
  • gt - Greater than
  • gte - Greater than or equal
  • lt - Less than
  • lte - Less than or equal

Data Transformations

Transform raw data before it reaches your application:
// When defining the stack
const MyStack = {
  name: 'my-app',
  url: 'wss://...',
  views: {
    tokens: {
      list: {
        mode: 'list' as const,
        view: 'Token/list',
      },
    },
  },
};

// Transform happens in the entity definition
interface Token {
  mint: string;
  supply: bigint; // Converted from string
  price: number;
}
Common transformations:
// Convert bigint strings to BigInt
supply: BigInt(raw.supply)

// Parse dates
created_at: new Date(raw.created_at)

// Flatten nested data
{
  mint: raw.id.mint,
  name: raw.info.name,
  volume: raw.trading.total_volume,
}

View Lifecycle

Get vs Get Sync

// get() - Async, ensures subscription
const tokens = await client.views.tokens.list.get();
// Waits for data to be loaded

// getSync() - Sync, returns cached data
const cached = client.views.tokens.list.getSync();
// Returns immediately, may be undefined

Store Access

Direct access to the underlying storage:
// Access the store directly
const store = client.store;

// Get all data for a view
const tokens = await store.getAll('Token/list');

// Get specific entity
const token = await store.get('Token/state', 'So11111...');

// Clear all cached data
client.clearStore();

Common Patterns

Conditional Loading

async function getTokenIfExists(mint: string | null) {
  if (!mint) return null;
  
  return await client.views.tokens.state.get(mint);
}

Combining Multiple Views

async function getDashboardData() {
  const [tokens, stats] = await Promise.all([
    client.views.tokens.list.get(),
    client.views.stats.state.get('global'),
  ]);

  return { tokens, stats };
}

Next Steps

Subscriptions

Subscribe to real-time updates

Transactions

Execute blockchain transactions

Build docs developers (and LLMs) love