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-1/

Solana Wallet Balance Tracker

A utility that retrieves and displays account balance information from the Solana blockchain, including both SOL and SPL token balances.

Capabilities

Retrieve SOL Balance

  • Given a public key string "9B5XszUGdMaxCZ7uSQhPzdks5ZQSmWxrmzCSvtJ6Ns6g", returns the SOL balance in lamports. @test
  • Given an invalid public key string "invalid", throws an error. @test

Retrieve Token Accounts

  • Given a wallet public key "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", retrieves all token accounts owned by that wallet. @test
  • Given a wallet with no token accounts, returns an empty array. @test

Parse Token Balance

  • Given a token account public key "AyHWro8zumyZN68Mvy87CgTJ17qd3LEz19rfyFkAw8p5", retrieves and returns the token balance information including amount and decimals. @test

Implementation

@generates

API

/**
 * Retrieves the SOL balance for a given wallet address.
 *
 * @param {string} publicKeyStr - The wallet address as a base58 string.
 * @param {string} clusterUrl - The Solana cluster RPC URL (e.g., "https://api.mainnet-beta.solana.com").
 * @returns {Promise<number>} The balance in lamports.
 * @throws {Error} If the public key is invalid.
 */
async function getSolBalance(publicKeyStr, clusterUrl) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves all SPL token accounts owned by a wallet.
 *
 * @param {string} ownerPublicKeyStr - The owner wallet address as a base58 string.
 * @param {string} clusterUrl - The Solana cluster RPC URL.
 * @returns {Promise<Array<Object>>} Array of token account objects with pubkey and account info.
 * @throws {Error} If the public key is invalid.
 */
async function getTokenAccounts(ownerPublicKeyStr, clusterUrl) {
  // IMPLEMENTATION HERE
}

/**
 * Retrieves the token balance for a specific token account.
 *
 * @param {string} tokenAccountPublicKeyStr - The token account address as a base58 string.
 * @param {string} clusterUrl - The Solana cluster RPC URL.
 * @returns {Promise<Object>} Object containing balance information with amount and decimals.
 * @throws {Error} If the token account public key is invalid.
 */
async function getTokenBalance(tokenAccountPublicKeyStr, clusterUrl) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getSolBalance,
  getTokenAccounts,
  getTokenBalance,
};

Dependencies { .dependencies }

@solana/web3.js { .dependency }

Provides Solana blockchain interaction capabilities including connection management, account queries, and balance retrieval.

Install with Tessl CLI

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

tile.json