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

Stake Account Management Tool

Overview

Build a command-line tool that helps users manage their Solana staking operations by providing utilities to split stake accounts into multiple smaller accounts and merge multiple stake accounts into a single account.

Requirements

Functionality

Your tool must support the following operations:

  1. Split Stake Account: Take an existing stake account and split it into multiple new stake accounts with specified amounts. The original account should retain any remaining lamports after the splits.

  2. Merge Stake Accounts: Take two or more stake accounts that belong to the same authority and merge them into a single stake account. All lamports should be consolidated into the target account.

Input Parameters

The tool should accept:

  • Connection endpoint URL (e.g., devnet, testnet, or mainnet-beta)
  • Operation type: "split" or "merge"
  • For split operations:
    • Source stake account address
    • Array of lamport amounts to split off
    • Authorized keypair (as a path to a JSON file containing the keypair)
  • For merge operations:
    • Target stake account address (where funds will be merged into)
    • Array of source stake account addresses to merge from
    • Authorized keypair (as a path to a JSON file containing the keypair)

Output

The tool should:

  • Display transaction signatures for all operations performed
  • Show the public keys of any newly created stake accounts
  • Provide clear error messages if operations fail

Implementation Details

  • Use appropriate transaction confirmation strategies
  • Handle errors gracefully with informative messages
  • Ensure all transactions are properly signed by the authorized keypair
  • Display operation progress to the user

Dependencies { .dependencies }

@solana/web3.js { .dependency }

Provides the core functionality for interacting with the Solana blockchain, including stake account operations.

Test Cases

Test Case 1: Split a Stake Account { .test-case @test }

Test File: split-stake.test.js

Setup:

  • Create a test keypair with sufficient funds
  • Create and initialize a stake account with 10 SOL
  • Delegate the stake to a validator

Operation: Split the stake account into two new accounts with 3 SOL and 2 SOL respectively.

Expected Outcome:

  • Original account retains 5 SOL (minus rent)
  • Two new stake accounts are created with 3 SOL and 2 SOL
  • All accounts maintain delegation status
  • Transaction signatures are returned successfully

Test Case 2: Merge Multiple Stake Accounts { .test-case @test }

Test File: merge-stake.test.js

Setup:

  • Create a test keypair with sufficient funds
  • Create three stake accounts: Account A (5 SOL), Account B (3 SOL), Account C (2 SOL)
  • Ensure all accounts are delegated to the same validator

Operation: Merge Account B and Account C into Account A.

Expected Outcome:

  • Account A contains 10 SOL (5 + 3 + 2)
  • Account B and Account C are closed and contain 0 lamports
  • Transaction signatures are returned for each merge operation
  • All delegation status is maintained in the target account

Test Case 3: Error Handling - Invalid Authority { .test-case @test }

Test File: error-handling.test.js

Setup:

  • Create two keypairs: owner and unauthorized
  • Create a stake account owned by the owner keypair

Operation: Attempt to split the stake account using the unauthorized keypair.

Expected Outcome:

  • Operation fails with a clear error message
  • Original stake account remains unchanged
  • No new accounts are created

Install with Tessl CLI

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

tile.json