solana_client 0.0.1 copy "solana_client: ^0.0.1" to clipboard
solana_client: ^0.0.1 copied to clipboard

A simple client for interacting with the Solana blockchain.

solana_client #

A simple and easy-to-use Flutter/Dart client for interacting with the Solana blockchain. This package provides a high-level interface for common Solana operations including balance queries, SOL transfers, SPL token operations, and transaction history retrieval.

Features #

  • 🔐 Mnemonic-based wallet management - Derive Solana keypairs from BIP39 mnemonic phrases
  • 💰 Balance queries - Get SOL and SPL token balances for any wallet
  • 📤 Token transfers - Send SOL and SPL tokens to any address
  • 📜 Transaction history - Retrieve transaction history for tokens
  • 🌐 Multi-network support - Connect to Solana mainnet-beta or devnet
  • 🔑 BIP44 derivation - Support for multiple accounts and change addresses from a single mnemonic

Getting started #

Add solana_client to your pubspec.yaml:

dependencies:
  solana_client: ^0.0.1

Then run:

flutter pub get

Usage #

Initialize the client #

import 'package:solana_client/solana_client.dart';

// Create a client for devnet
final client = SolanaClient(
  network: SolanaNetwork.devnet,
  mnemonic: 'your twelve word mnemonic phrase goes here',
  account: 0,
  change: 0,
);

// Or for mainnet-beta
final mainnetClient = SolanaClient(
  network: SolanaNetwork.mainnetBeta,
  mnemonic: 'your twelve word mnemonic phrase goes here',
);

Generate a new mnemonic #

import 'package:solana_client/solana_utils.dart';

// Generate a new 12-word mnemonic
final mnemonic = await SolanaUtils.generateMnemonic();
print('Your mnemonic: $mnemonic');

Get wallet address #

final address = await client.getAddress();
print('Wallet address: $address');

Check SOL balance #

final balance = await client.getSolanaBalance();
print('SOL balance: $balance');

Check token balance #

final tokenBalance = await client.getTokenBalance(
  tokenMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
);
print('Token balance: $tokenBalance');

Send SOL #

final response = await client.sendSolana(
  to: 'RecipientWalletAddressHere',
  amount: 0.1, // Amount in SOL
);

if (response.success) {
  print('Transaction successful: ${response.signature}');
} else {
  print('Transaction failed: ${response.error}');
}

Send tokens #

final response = await client.sendToken(
  to: 'RecipientWalletAddressHere',
  tokenMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  amount: 10.0, // Amount in token units
);

if (response.success) {
  print('Token transfer successful: ${response.signature}');
} else {
  print('Token transfer failed: ${response.error}');
}

Get token transaction history #

final transactions = await client.getTokenTransactions(
  tokenMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
  limit: 10,
);

for (final tx in transactions) {
  print('Transaction: $tx');
}

Additional information #

This package is built on top of the solana package and provides a simplified, high-level API for common Solana blockchain operations.

Security Note #

⚠️ Never commit your mnemonic phrases or private keys to version control. Always use secure storage solutions for production applications.

Dependencies #

  • solana: ^0.32.0 - Core Solana functionality
  • bip39: ^1.0.6 - BIP39 mnemonic generation and validation

License #

This package is licensed under the MIT License. See the LICENSE file for details.

1
likes
0
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

A simple client for interacting with the Solana blockchain.

Homepage

License

unknown (license)

Dependencies

bip39, flutter, solana

More

Packages that depend on solana_client