Skip to content

Wallet Balance Query - SOL balance retrieval implementation #125

@Haydart

Description

@Haydart

name: Wallet Balance Query - SOL balance retrieval implementation
status: open
created: 2025-09-19T16:02:24Z
updated: 2025-09-19T16:42:04Z
github: #125
depends_on: [127, 129, 124]
parallel: false
conflicts_with: []

Task: Wallet Balance Query - SOL balance retrieval implementation

Description

Implement the get_wallet_balance() method in the SolanaBlockchainService class to retrieve SOL balance for a given wallet address. This method provides the foundation for wallet balance queries and serves as the simplest blockchain data retrieval operation in the service.

Acceptance Criteria

  • get_wallet_balance(address: str) -> Optional[float] method implemented
  • Proper SOL balance conversion from lamports to SOL (division by 1e9)
  • Address validation before making RPC calls
  • Error handling for invalid addresses and network failures
  • Retry logic implementation with exponential backoff
  • Return None for addresses with zero balance or non-existent accounts
  • Unit tests will be handled in Unit Testing - Comprehensive test suite with mocked responses #128

Technical Details

Implementation Approach

  • Use solana.rpc.api.Client.get_balance() method for balance retrieval
  • Convert lamports to SOL using standard Solana conversion (1 SOL = 1e9 lamports)
  • Implement address validation using Solana address format checks
  • Apply retry logic with exponential backoff for network failures
  • Handle RPC errors gracefully with meaningful error messages

Key Considerations

  • Precision: Use float for SOL amounts with proper lamport conversion
  • Error Recovery: Distinguish between permanent errors (invalid address) and temporary errors (network issues)
  • Edge Cases: Handle zero balances, non-existent accounts, and malformed addresses

Code Locations/Files Affected

  • src/services/solana_blockchain_service.py (get_wallet_balance method)

Dependencies

Effort Estimate

  • Size: S
  • Hours: 3-4 hours
  • Parallel: false (requires core service foundation)

Definition of Done

  • get_wallet_balance method implemented and functional
  • Proper lamport to SOL conversion verified
  • Address validation working for valid/invalid Solana addresses
  • Error handling tested for network failures and invalid inputs
  • Retry logic functioning with exponential backoff
  • Unit tests will be handled in Unit Testing - Comprehensive test suite with mocked responses #128
  • Method returns correct Optional[float] type as per interface

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions