CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-solana--web3-js

Comprehensive JavaScript SDK for building Solana blockchain applications with modern architecture and type safety

93

1.29x

Evaluation93%

1.29x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-10/

Account Balance Consistency Tracker

Build a utility that fetches and tracks Solana account balances while maintaining consistency awareness across multiple queries using slot context information.

Requirements

Your implementation should provide functionality to:

  1. Fetch multiple account balances - Query the balances of multiple Solana accounts in a single operation
  2. Track query freshness - Capture and store the slot number at which each balance query was executed
  3. Detect stale data - Compare slot contexts between queries to identify when data may be from different blockchain states
  4. Report consistency status - Indicate whether a set of balance queries were executed at the same slot (consistent) or different slots (potentially inconsistent)

Behavior

  • When fetching balances for a list of accounts, the tool should query all accounts and return their balances along with the slot context
  • The slot context should indicate the point in time (by slot number) when the blockchain state was queried
  • When comparing multiple balance snapshots, the tool should identify if they were taken at the same slot or different slots
  • If balances are from different slots, this should be clearly indicated as they may represent inconsistent states

Test Cases

  • Fetching balances for 3 valid accounts returns balance data with slot context information @test
  • Comparing two balance snapshots from the same slot indicates they are consistent @test
  • Comparing two balance snapshots from different slots indicates they are inconsistent @test

Implementation

@generates

API

/**
 * Fetches balances for multiple accounts with slot context
 * @param {Connection} connection - Solana RPC connection
 * @param {PublicKey[]} accounts - Array of account public keys
 * @returns {Promise<{balances: number[], slot: number}>} Balance data with slot context
 */
async function fetchBalances(connection, accounts) {
  // Implementation
}

/**
 * Compares two balance snapshots for consistency
 * @param {{balances: number[], slot: number}} snapshot1 - First balance snapshot
 * @param {{balances: number[], slot: number}} snapshot2 - Second balance snapshot
 * @returns {{consistent: boolean, slot1: number, slot2: number}} Consistency result
 */
function checkConsistency(snapshot1, snapshot2) {
  // Implementation
}

Dependencies { .dependencies }

@solana/web3.js { .dependency }

Provides Solana blockchain RPC communication and account management.

Install with Tessl CLI

npx tessl i tessl/npm-solana--web3-js

tile.json