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

Transaction Simulator

Build a command-line tool that simulates Solana transactions before sending them to the network, providing detailed insights about the transaction execution.

Requirements

Create a transaction simulator that:

  1. Accepts a serialized transaction (base64-encoded) as input
  2. Simulates the transaction against the Solana devnet without actually submitting it
  3. Outputs simulation results including:
    • Success or failure status
    • Compute units consumed
    • Program logs from execution
    • Any errors encountered during simulation

The tool should handle both successful simulations and transactions that would fail, providing clear diagnostic information in either case.

Input

The tool should accept a base64-encoded serialized transaction string as a command-line argument.

Output

For successful simulations, output:

  • "Status: Success"
  • "Compute units: [number]"
  • "Logs:" followed by each log line

For failed simulations, output:

  • "Status: Failed"
  • "Error: [error message]"
  • Any available logs

Test Cases

Valid transaction simulation

  • Given a valid serialized transaction, the simulator connects to devnet and returns simulation results with status, compute units, and logs @test

Failed transaction simulation

  • Given a transaction that would fail (e.g., insufficient funds), the simulator returns failure status with error details @test

Invalid input handling

  • Given an invalid base64 string, the tool reports an error about malformed input @test

Implementation

@generates

API

/**
 * Simulates a transaction on Solana devnet
 *
 * @param {string} serializedTransaction - Base64-encoded transaction
 * @returns {Promise<{status: string, computeUnits?: number, logs?: string[], error?: string}>}
 */
async function simulateTransaction(serializedTransaction) {
  // IMPLEMENTATION HERE
}

module.exports = { simulateTransaction };

Dependencies { .dependencies }

@solana/web3.js { .dependency }

Provides Solana blockchain connectivity and transaction simulation capabilities.

Install with Tessl CLI

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

tile.json